From 62f1204476c788e51d09e62d168fad14fd39e075 Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Sun, 7 Aug 2011 17:49:46 +0000 Subject: [PATCH] ---------------------- Genesis Plus GX 1.6.0 ---------------------- [Core/Sound] --------------- * added YM2413 emulation in Master System compatibility mode. * fixed SN76489 noise boost initialization. * minor YM2612 core optimizations. [Core/VDP] --------------- * added accurate emulation of SG-1000, Master System (315-5124, 315-5246) & Game Gear VDP. * added support for all TMS9918 rendering modes. * improved Mega Drive VDP timings accuracy in Master System Compatibility mode. * fixed color palette initialization. * fixed shifted sprites rendering in Mode 4. * modified pixel rendering support (pixel depth is now forced at compilation time). [Core/CPU] --------------- * optimized 68k core (rewrote 68k interrupt handling, removed multiple CPU types support & unused code) for 5~8% speed improvment [Core/IO] --------------- * added accurate emulation of Master System (315-5216, 315-5237, 315-5297) & Game Gear I/O controllers. * added Terebi Oekaki tablet emulation. * improved Mouse emulation (fixes mouse support in Cannon Fodder). * improved Justifier emulation (fixes gun support in Lethal Enforcers 2). * improved 6-Buttons control pad emulation (fixes Duke Nukem 3D) * modified lightgun emulation to use common key inputs for all devices. * 2-buttons controller is now picked by default for Master System games. [Core/MD] --------------- * added copy-protection hardware emulation for some new dumped games (Tiny Toon Adventures 3, Mighty Morphin Power Rangers & The Battle of Red Cliffs). * added Game Toshokan in EEPROM database (verified on real cartridge). * fixed Micro Machines 2 - Turbo Tournament EEPROM size (verified on real cartridge). * modified SRAM banswitch hardware emulation to be more compatible with some hacks. [Core/MS] --------------- * added Cyborg Z to Korean mapper database. [Core/GG] --------------- * added 93C46 EEPROM emulation (Majors Pro Baseball, World Series Baseball & World Series Baseball 95). [Core/General] --------------- * added support for .mdx ROM format. * added Game Gear & SG-1000 ROM support. * added accurate emulation of SG-1000, Master System (I, II) & Game Gear hardware models for 100% compatibility. * updated to new Genesis Plus license (see http://cgfm2.emuviews.com/) * removed DOS port * various code cleanup. [Gamecube/Wii] --------------- * IMPORTANT: cheats, screenshots & save files are now stored in console-specific directories (ex: /snaps/md, /cheats/ms, /saves/gg, ...) * added 8-bit Action Replay & Game Genie codes support (for Master System & Game Gear games). * improved audio/video synchronization for PAL games in 50Hz TV modes (now use VSYNC like NTSC games in 60hz modes). * improved gun cursor positioning accuracy. * improved horizontal scaling & screenshots rendering in H32 mode. * fixed a bug with ROM file extension handling that would affect cheats, snapshots, sram & savestate files. * removed ARAM/injected ROM support (unused). * removed WPAD_ and PAD_ update from VSYNC callback. * increased GCC inlining limits for some speed improvment. * compiled with devkitPPC r24 & libogc 1.8.7. --- LICENSE.txt | 440 - Makefile.gc | 8 +- Makefile.wii | 4 +- Makefile.win32 | 133 + source/cart_hw/areplay.c | 43 +- source/cart_hw/areplay.h | 43 +- source/cart_hw/eeprom.c | 462 - source/cart_hw/gg_eeprom.c | 259 + source/cart_hw/gg_eeprom.h | 75 + source/cart_hw/ggenie.c | 56 +- source/cart_hw/ggenie.h | 43 +- source/cart_hw/md_cart.c | 149 +- source/cart_hw/md_cart.h | 53 +- source/cart_hw/md_eeprom.c | 554 + source/cart_hw/{eeprom.h => md_eeprom.h} | 61 +- source/cart_hw/sms_cart.c | 612 +- source/cart_hw/sms_cart.h | 49 +- source/cart_hw/sram.c | 42 +- source/cart_hw/sram.h | 40 +- source/cart_hw/svp/ssp16.c | 11 +- source/genesis.c | 230 +- source/genesis.h | 42 +- source/gx/aram.c | 64 - source/gx/aram.h | 31 - source/gx/config.c | 63 +- source/gx/config.h | 47 +- source/gx/fileio/file_load.c | 198 +- source/gx/fileio/file_load.h | 51 +- source/gx/fileio/file_slot.c | 65 +- source/gx/fileio/file_slot.h | 43 +- source/gx/fileio/fileio.c | 265 + source/gx/fileio/fileio.h | 48 + source/gx/fileio/history.c | 42 +- source/gx/fileio/history.h | 42 +- source/gx/gui/cheats.c | 478 +- source/gx/gui/cheats.h | 46 +- source/gx/gui/filesel.c | 210 +- source/gx/gui/filesel.h | 44 +- source/gx/gui/font.c | 46 +- source/gx/gui/font.h | 44 +- source/gx/gui/gui.c | 42 +- source/gx/gui/gui.h | 42 +- source/gx/gui/legal.c | 58 +- source/gx/gui/menu.c | 533 +- source/gx/gui/menu.h | 44 +- source/gx/gx_audio.c | 45 +- source/gx/gx_audio.h | 43 +- source/gx/gx_input.c | 384 +- source/gx/gx_input.h | 44 +- source/gx/gx_video.c | 198 +- source/gx/gx_video.h | 44 +- source/gx/images/Banner_main.png | Bin 20675 -> 23123 bytes source/gx/main.c | 313 +- source/gx/osd.h | 15 +- source/gx/utils/oggplayer.h | 3 + source/gx/utils/vi_encoder.c | 44 +- source/gx/utils/vi_encoder.h | 43 +- source/hvc.h | 40 +- source/input_hw/activator.c | 40 +- source/input_hw/activator.h | 40 +- source/input_hw/gamepad.c | 52 +- source/input_hw/gamepad.h | 44 +- source/input_hw/input.c | 119 +- source/input_hw/input.h | 67 +- source/input_hw/lightgun.c | 64 +- source/input_hw/lightgun.h | 40 +- source/input_hw/mouse.c | 40 +- source/input_hw/mouse.h | 40 +- source/input_hw/paddle.c | 40 +- source/input_hw/paddle.h | 40 +- source/input_hw/sportspad.c | 40 +- source/input_hw/sportspad.h | 40 +- source/input_hw/teamplayer.c | 42 +- source/input_hw/teamplayer.h | 40 +- source/input_hw/terebi_oekaki.c | 77 + source/input_hw/terebi_oekaki.h | 47 + source/input_hw/xe_a1p.c | 40 +- source/input_hw/xe_a1p.h | 40 +- source/io_ctrl.c | 256 +- source/io_ctrl.h | 57 +- source/loadrom.c | 148 +- source/loadrom.h | 42 +- source/m68k/m68k.h | 238 +- source/m68k/m68kCycleAccurate.h | 213 - source/m68k/m68kconf.h | 109 +- source/m68k/m68kcpu.c | 1007 +- source/m68k/m68kcpu.h | 1081 +- source/m68k/m68kops.c | 37084 --------------------- source/m68k/m68kops.h | 25425 +++++++++++++- source/mem68k.c | 112 +- source/mem68k.h | 48 +- source/membnk.c | 45 +- source/membnk.h | 41 +- source/memz80.c | 501 +- source/memz80.h | 63 +- source/shared.h | 3 +- source/sound/Fir_Resampler.c | 28 +- source/sound/Fir_Resampler.h | 16 +- source/sound/sn76489.c | 40 +- source/sound/sn76489.h | 3 +- source/sound/sound.c | 52 +- source/sound/sound.h | 42 +- source/sound/ym2413.c | 34 +- source/sound/ym2612.c | 355 +- source/state.c | 136 +- source/state.h | 42 +- source/system.c | 336 +- source/system.h | 68 +- source/types.h | 19 - source/vdp_ctrl.c | 1329 +- source/vdp_ctrl.h | 51 +- source/vdp_render.c | 1467 +- source/vdp_render.h | 64 +- HISTORY.txt => source/win/CHANGELOG.txt | 601 +- source/win/LICENSE.txt | 552 + source/win/README.txt | 130 + source/win/config.c | 50 + source/win/config.h | 51 + source/win/error.c | 30 + source/win/error.h | 13 + source/win/fileio.c | 182 + source/win/fileio.h | 50 + source/win/icon.rc | 1 + source/win/main.c | 780 + source/win/main.h | 10 + source/win/md.ico | Bin 0 -> 42126 bytes source/win/osd.h | 29 + source/win/readme-sdl.txt | 5 + source/win/unzip.c | 1294 + source/win/unzip.h | 273 + source/z80/z80.c | 14 +- source/z80/z80.h | 5 +- 132 files changed, 38637 insertions(+), 44151 deletions(-) delete mode 100644 LICENSE.txt create mode 100644 Makefile.win32 delete mode 100644 source/cart_hw/eeprom.c create mode 100644 source/cart_hw/gg_eeprom.c create mode 100644 source/cart_hw/gg_eeprom.h create mode 100644 source/cart_hw/md_eeprom.c rename source/cart_hw/{eeprom.h => md_eeprom.h} (53%) delete mode 100644 source/gx/aram.c delete mode 100644 source/gx/aram.h create mode 100644 source/gx/fileio/fileio.c create mode 100644 source/gx/fileio/fileio.h create mode 100644 source/input_hw/terebi_oekaki.c create mode 100644 source/input_hw/terebi_oekaki.h delete mode 100644 source/m68k/m68kCycleAccurate.h delete mode 100644 source/m68k/m68kops.c rename HISTORY.txt => source/win/CHANGELOG.txt (57%) create mode 100644 source/win/LICENSE.txt create mode 100644 source/win/README.txt create mode 100644 source/win/config.c create mode 100644 source/win/config.h create mode 100644 source/win/error.c create mode 100644 source/win/error.h create mode 100644 source/win/fileio.c create mode 100644 source/win/fileio.h create mode 100644 source/win/icon.rc create mode 100644 source/win/main.c create mode 100644 source/win/main.h create mode 100644 source/win/md.ico create mode 100644 source/win/osd.h create mode 100644 source/win/readme-sdl.txt create mode 100644 source/win/unzip.c create mode 100644 source/win/unzip.h diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 03eca29..0000000 --- a/LICENSE.txt +++ /dev/null @@ -1,440 +0,0 @@ -MAME License: -------------- - -Redistribution and use of this code or any derivative works are permitted -provided that the following conditions are met: - -* Redistributions may not be sold, nor may they be used in a commercial -product or activity. - -* Redistributions that are modified from the original source must include the -complete source code, including the source code for all components used by a -binary built from the modified sources. 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. - -* Redistributions must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or other -materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - - - -LIBTREMOR license: ------------------- - -Copyright (c) 2002, Xiph.org Foundation - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -- Neither the name of the Xiph.org Foundation nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -ASNDLIB License: ----------------- - -Copyright (c) 2008 Francisco Muņoz 'Hermes' -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, this list of - conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, this list - of conditions and the following disclaimer in the documentation and/or other - materials provided with the distribution. -- The names of the contributors may not be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -GNU License: ------------- - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser 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., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 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 Lesser General -Public License instead of this License. diff --git a/Makefile.gc b/Makefile.gc index 6978400..aa238d4 100644 --- a/Makefile.gc +++ b/Makefile.gc @@ -19,15 +19,15 @@ TARGET := genplus_cube BUILD := build_cube SOURCES := source source/m68k source/z80 source/sound source/ntsc source/input_hw source/cart_hw source/cart_hw/svp \ source/gx source/gx/utils source/gx/gui source/gx/fileio source/gx/images source/gx/sounds -INCLUDES := source source/m68k source/z80 source/sound source/ntsc source/input_hw source/cart_hw source/cart_hw/svp \ +INCLUDES := source source/m68k source/z80 source/sound source/ntsc source/input_hw source/cart_hw source/cart_hw/svp \ source/gx source/gx/utils source/gx/gui source/gx/fileio source/gx/images source/gx/sounds \ - $(BUILD) + $(BUILD) #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- -CFLAGS = -O3 -fomit-frame-pointer -Wall -Wno-strict-aliasing $(MACHDEP) $(INCLUDE) -DALT_RENDERER -DNGC -DHW_DOL +CFLAGS = -O3 -fomit-frame-pointer --param large-function-growth=800 --param inline-unit-growth=200 -Wall -Winline -Wno-strict-aliasing $(MACHDEP) $(INCLUDE) -DUSE_16BPP_RENDERING -DALT_RENDERER -DNGC -DHW_DOL CXXFLAGS = $(CFLAGS) LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map @@ -95,7 +95,7 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ # build a list of library paths #--------------------------------------------------------------------------------- export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ - -L$(LIBOGC_LIB) + -L$(LIBOGC_LIB) export OUTPUT := $(CURDIR)/$(TARGET) .PHONY: $(BUILD) clean diff --git a/Makefile.wii b/Makefile.wii index a8bd665..9653055 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -27,7 +27,7 @@ INCLUDES := source source/m68k source/z80 source/sound source/ntsc source/input_ # options for code generation #--------------------------------------------------------------------------------- -CFLAGS = -O3 -fomit-frame-pointer -Wall -Wno-strict-aliasing $(MACHDEP) $(INCLUDE) -DALT_RENDERER -DNGC -DHW_RVL +CFLAGS = -O3 -fomit-frame-pointer --param large-function-growth=800 --param inline-unit-growth=200 -Wall -Winline -Wno-strict-aliasing $(MACHDEP) $(INCLUDE) -DUSE_16BPP_RENDERING -DALT_RENDERER -DNGC -DHW_RVL CXXFLAGS = $(CFLAGS) LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map @@ -53,7 +53,7 @@ ifneq ($(BUILD),$(notdir $(CURDIR))) export OUTPUT := $(CURDIR)/$(TARGET) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) + $(foreach dir,$(DATA),$(CURDIR)/$(dir)) export DEPSDIR := $(CURDIR)/$(BUILD) diff --git a/Makefile.win32 b/Makefile.win32 new file mode 100644 index 0000000..13dd88c --- /dev/null +++ b/Makefile.win32 @@ -0,0 +1,133 @@ + +# Makefile for genplus SDL +# +# (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald +# modified by Eke-Eke +# +# Defines : +# -DLSB_FIRST : for little endian systems. +# -DLOGERROR : enable message logging +# -DLOGVDP : enable VDP debug messages +# -DLOGSOUND : enable AUDIO debug messages +# -D8BPP_RENDERING - configure for 8-bit pixels (RGB332) +# -D15BPP_RENDERING - configure for 15-bit pixels (RGB555) +# -D16BPP_RENDERING - configure for 16-bit pixels (RGB565) +# -D32BPP_RENDERING - configure for 32-bit pixels (RGB888) + +NAME = gen_sdl.exe + +CC = gcc +CFLAGS = `sdl-config --cflags` -march=i686 -O6 -fomit-frame-pointer -Wall -Wno-strict-aliasing +#-g -ggdb -pg +#-fomit-frame-pointer +#LDFLAGS = -pg +DEFINES = -DLSB_FIRST -DUSE_16BPP_RENDERING + +INCLUDES = -Isource -Isource/z80 -Isource/m68k -Isource/sound -Isource/input_hw -Isource/cart_hw -Isource/cart_hw/svp -Isource/ntsc -Isource/win +LIBS = `sdl-config --libs` -lz -lm + +OBJDIR = ./build_sdl + +OBJECTS = $(OBJDIR)/z80.o + +OBJECTS += $(OBJDIR)/m68kcpu.o + +OBJECTS += $(OBJDIR)/genesis.o \ + $(OBJDIR)/vdp_ctrl.o \ + $(OBJDIR)/vdp_render.o \ + $(OBJDIR)/system.o \ + $(OBJDIR)/io_ctrl.o \ + $(OBJDIR)/mem68k.o \ + $(OBJDIR)/memz80.o \ + $(OBJDIR)/membnk.o \ + $(OBJDIR)/state.o \ + $(OBJDIR)/loadrom.o + +OBJECTS += $(OBJDIR)/input.o \ + $(OBJDIR)/gamepad.o \ + $(OBJDIR)/lightgun.o \ + $(OBJDIR)/mouse.o \ + $(OBJDIR)/activator.o \ + $(OBJDIR)/xe_a1p.o \ + $(OBJDIR)/teamplayer.o \ + $(OBJDIR)/paddle.o \ + $(OBJDIR)/sportspad.o \ + $(OBJDIR)/terebi_oekaki.o + +OBJECTS += $(OBJDIR)/sound.o \ + $(OBJDIR)/sn76489.o \ + $(OBJDIR)/ym2413.o \ + $(OBJDIR)/ym2612.o + +OBJECTS += $(OBJDIR)/Fir_Resampler.o +OBJECTS += $(OBJDIR)/blip.o +OBJECTS += $(OBJDIR)/eq.o + +OBJECTS += $(OBJDIR)/sram.o \ + $(OBJDIR)/svp.o \ + $(OBJDIR)/ssp16.o \ + $(OBJDIR)/ggenie.o \ + $(OBJDIR)/areplay.o \ + $(OBJDIR)/gg_eeprom.o \ + $(OBJDIR)/md_eeprom.o \ + $(OBJDIR)/md_cart.o \ + $(OBJDIR)/sms_cart.o + +OBJECTS += $(OBJDIR)/sms_ntsc.o \ + $(OBJDIR)/md_ntsc.o + +OBJECTS += $(OBJDIR)/main.o \ + $(OBJDIR)/config.o \ + $(OBJDIR)/error.o \ + $(OBJDIR)/unzip.o \ + $(OBJDIR)/fileio.o + +OBJECTS += $(OBJDIR)/icon.o + +all: $(NAME) + +$(NAME): $(OBJDIR) $(OBJECTS) + $(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@ + +$(OBJDIR) : + @[ -d $@ ] || mkdir -p $@ + +$(OBJDIR)/%.o : source/%.c source/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/sound/%.c source/sound/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/input_hw/%.c source/input_hw/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/cart_hw/%.c source/cart_hw/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/cart_hw/svp/%.c + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/cart_hw/svp/%.c source/cart_hw/svp/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/z80/%.c source/z80/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/m68k/%.c source/m68k/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/ntsc/%.c source/ntsc/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/%.o : source/win/%.c source/win/%.h + $(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@ + +$(OBJDIR)/icon.o : + windres source/win/icon.rc $@ + +pack : + strip $(NAME) + upx -9 $(NAME) + +clean: + rm -f $(OBJECTS) $(NAME) diff --git a/source/cart_hw/areplay.c b/source/cart_hw/areplay.c index 4dbd424..1b3e8b1 100644 --- a/source/cart_hw/areplay.c +++ b/source/cart_hw/areplay.c @@ -2,22 +2,39 @@ * Genesis Plus * Action Replay / Pro Action Replay emulation * - * Copyright (C) 2009 Eke-Eke (GCN/Wii port) + * Copyright (C) 2009-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 - ***************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" diff --git a/source/cart_hw/areplay.h b/source/cart_hw/areplay.h index 64ae9a8..5f1befd 100644 --- a/source/cart_hw/areplay.h +++ b/source/cart_hw/areplay.h @@ -2,22 +2,39 @@ * Genesis Plus * DATEL Action Replay / Pro Action Replay emulation * - * Copyright (C) 2009 Eke-Eke (GCN/Wii port) + * Copyright (C) 2009-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 - ***************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _AREPLAY_H_ #define _AREPLAY_H_ diff --git a/source/cart_hw/eeprom.c b/source/cart_hw/eeprom.c deleted file mode 100644 index b2d8955..0000000 --- a/source/cart_hw/eeprom.c +++ /dev/null @@ -1,462 +0,0 @@ -/**************************************************************************** - * Genesis Plus - * I2C EEPROM support - * - * Copyright (C) 2007, 2008, 2009 Eke-Eke (GCN/Wii port) - * - * 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 - ***************************************************************************/ - -#include "shared.h" - -#define GAME_CNT 30 - -T_EEPROM eeprom; - -typedef struct -{ - char game_id[16]; - uint16 chk; - T_EEPROM_TYPE type; -} T_GAME_ENTRY; - -static const T_GAME_ENTRY database[GAME_CNT] = -{ - /* ACCLAIM mappers */ - /* 24C02 (old mapper) */ - {{"T-081326" }, 0, {8, 0xFF, 0xFF, 0x200001, 0x200001, 0x200001, 0, 1, 1}}, /* NBA Jam (UE) */ - {{"T-81033" }, 0, {8, 0xFF, 0xFF, 0x200001, 0x200001, 0x200001, 0, 1, 1}}, /* NBA Jam (J) */ - /* 24C02 */ - {{"T-081276" }, 0, {8, 0xFF, 0xFF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* NFL Quarterback Club */ - /* 24C04 */ - {{"T-81406" }, 0, {8, 0x1FF, 0x1FF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* NBA Jam TE */ - /* 24C16 */ - {{"T-081586" }, 0, {8, 0x7FF, 0x7FF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* NFL Quarterback Club '96 */ - /* 24C65 */ - {{"T-81576" }, 0, {16, 0x1FFF, 0x1FFF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* College Slam */ - {{"T-81476" }, 0, {16, 0x1FFF, 0x1FFF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* Frank Thomas Big Hurt Baseball */ - - /* EA mapper (24C01 only) */ - {{"T-50176" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* Rings of Power */ - {{"T-50396" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* NHLPA Hockey 93 */ - {{"T-50446" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* John Madden Football 93 */ - {{"T-50516" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* John Madden Football 93 (Championship Ed.) */ - {{"T-50606" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* Bill Walsh College Football */ - - /* SEGA mapper (24C01 only) */ - {{"T-12046" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Megaman - The Wily Wars */ - {{"T-12053" }, 0xEA80, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Rockman Mega World (J) [A] */ - {{"MK-1215" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Evander 'Real Deal' Holyfield's Boxing */ - {{"MK-1228" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Greatest Heavyweights of the Ring (U) */ - {{"G-5538" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Greatest Heavyweights of the Ring (J) */ - {{"PR-1993" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Greatest Heavyweights of the Ring (E) */ - {{"G-4060" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Wonderboy in Monster World */ - {{"00001211-00"}, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Sports Talk Baseball */ - {{"00004076-00"}, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Honoo no Toukyuuji Dodge Danpei */ - {{"G-4524" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Ninja Burai Densetsu */ - {{"00054503-00"}, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Game Toshokan */ - - /* CODEMASTERS mapper */ - /* 24C08 */ - {{"T-120106" }, 0, {8, 0x3FF, 0x3FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Brian Lara Cricket */ - {{"00000000-00"}, 0x168B, {8, 0x3FF, 0x3FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines Military */ - {{"00000000-00"}, 0xCEE0, {8, 0x3FF, 0x3FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines Military (Bad)*/ - /* 24C16 */ - {{"T-120096" }, 0, {8, 0x7FF, 0x7FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines 2 - Turbo Tournament (E) */ - {{"00000000-00"}, 0x165E, {8, 0x7FF, 0x7FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines Turbo Tournament 96 */ - {{"00000000-00"}, 0x2C41, {8, 0x7FF, 0x7FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines Turbo Tournament 96 (Bad)*/ - /* 24C65 */ - {{"T-120146-50"}, 0, {16, 0x1FFF, 0x1FFF, 0x300000, 0x380001, 0x300000, 0, 7, 1}} /* Brian Lara Cricket 96, Shane Warne Cricket */ -}; - -void eeprom_init() -{ - int i = 0; - - /* initialize eeprom */ - memset(&eeprom, 0, sizeof(T_EEPROM)); - eeprom.sda = eeprom.old_sda = 1; - eeprom.scl = eeprom.old_scl = 1; - eeprom.state = STAND_BY; - - /* no eeprom by default */ - sram.custom = 0; - - /* look into game database */ - while (i> (8 + eeprom.type.sda_in_bit)) & 1; /* MSB */ - else if (eeprom.type.sda_in_adr == (address | 1)) eeprom.sda = (data >> eeprom.type.sda_in_bit) & 1; /* LSB */ - else eeprom.sda = eeprom.old_sda; - - if (eeprom.type.scl_adr == address) eeprom.scl = (data >> (8 + eeprom.type.scl_bit)) & 1; /* MSB */ - else if (eeprom.type.scl_adr == (address | 1)) eeprom.scl = (data >> eeprom.type.scl_bit) & 1; /* LSB */ - else eeprom.scl = eeprom.old_scl; - } - else - { - if (eeprom.type.sda_in_adr == address) eeprom.sda = (data >> eeprom.type.sda_in_bit) & 1; - else eeprom.sda = eeprom.old_sda; - - if (eeprom.type.scl_adr == address) eeprom.scl = (data >> eeprom.type.scl_bit) & 1; - else eeprom.scl = eeprom.old_scl; - } - - /* EEPROM current state */ - switch (eeprom.state) - { - /* Standby Mode */ - case STAND_BY: - Detect_START(); - Detect_STOP(); - break; - - /* Suspended Mode */ - case WAIT_STOP: - Detect_STOP(); - break; - - /* Get Word Address 7 bits: MODE-1 only (24C01) - * and R/W bit - */ - case GET_WORD_ADR_7BITS: - Detect_START(); - Detect_STOP(); - - /* look for SCL LOW to HIGH transition */ - if (!eeprom.old_scl && eeprom.scl) - { - if (eeprom.cycles == 0) eeprom.cycles ++; - } - - - /* look for SCL HIGH to LOW transition */ - if (eeprom.old_scl && !eeprom.scl && (eeprom.cycles > 0)) - { - if (eeprom.cycles < 8) - { - eeprom.word_address |= (eeprom.old_sda << (7 - eeprom.cycles)); - } - else if (eeprom.cycles == 8) - { - eeprom.rw = eeprom.old_sda; - } - else - { /* ACK CYCLE */ - eeprom.cycles = 0; - eeprom.word_address &= eeprom.type.size_mask; - eeprom.state = eeprom.rw ? READ_DATA : WRITE_DATA; - } - - eeprom.cycles ++; - } - break; - - - /* Get Slave Address (3bits) : MODE-2 & MODE-3 only (24C01 - 24C512) (0-3bits, depending on the array size) - * or/and Word Address MSB: MODE-2 only (24C04 - 24C16) (0-3bits, depending on the array size) - * and R/W bit - */ - case GET_SLAVE_ADR: - - Detect_START(); - Detect_STOP(); - - /* look for SCL LOW to HIGH transition */ - if (!eeprom.old_scl && eeprom.scl) - { - if (eeprom.cycles == 0) eeprom.cycles ++; - } - - /* look for SCL HIGH to LOW transition */ - if (eeprom.old_scl && !eeprom.scl && (eeprom.cycles > 0)) - { - if ((eeprom.cycles > 4) && (eeprom.cycles <8)) - { - if ((eeprom.type.address_bits == 16) || - (eeprom.type.size_mask < (1 << (15 - eeprom.cycles)))) - { - /* this is a SLAVE ADDRESS bit */ - eeprom.slave_mask |= (eeprom.old_sda << (7 - eeprom.cycles)); - } - else - { - /* this is a WORD ADDRESS high bit */ - if (eeprom.old_sda) eeprom.word_address |= (1 << (15 - eeprom.cycles)); - else eeprom.word_address &= ~(1 << (15 - eeprom.cycles)); - } - } - else if (eeprom.cycles == 8) eeprom.rw = eeprom.old_sda; - else if (eeprom.cycles > 8) - { - /* ACK CYCLE */ - eeprom.cycles = 0; - if (eeprom.type.address_bits == 16) - { - /* two ADDRESS bytes */ - eeprom.state = eeprom.rw ? READ_DATA : GET_WORD_ADR_HIGH; - eeprom.slave_mask <<= 16; - } - else - { - /* one ADDRESS byte */ - eeprom.state = eeprom.rw ? READ_DATA : GET_WORD_ADR_LOW; - eeprom.slave_mask <<= 8; - } - } - - eeprom.cycles ++; - } - break; - - /* Get Word Address MSB (4-8bits depending on the array size) - * MODE-3 only (24C32 - 24C512) - */ - case GET_WORD_ADR_HIGH: - - Detect_START(); - Detect_STOP(); - - /* look for SCL HIGH to LOW transition */ - if (eeprom.old_scl && !eeprom.scl) - { - if (eeprom.cycles < 9) - { - if ((eeprom.type.size_mask + 1) < (1 << (17 - eeprom.cycles))) - { - /* ignored bit: slave mask should be right-shifted by one */ - eeprom.slave_mask >>= 1; - } - else - { - /* this is a WORD ADDRESS high bit */ - if (eeprom.old_sda) eeprom.word_address |= (1 << (16 - eeprom.cycles)); - else eeprom.word_address &= ~(1 << (16 - eeprom.cycles)); - } - - eeprom.cycles ++; - } - else - { - /* ACK CYCLE */ - eeprom.cycles = 1; - eeprom.state = GET_WORD_ADR_LOW; - } - } - break; - - - /* Get Word Address LSB: 7bits (24C01) or 8bits (24C02-24C512) - * MODE-2 and MODE-3 only (24C01 - 24C512) - */ - case GET_WORD_ADR_LOW: - - Detect_START(); - Detect_STOP(); - - /* look for SCL HIGH to LOW transition */ - if (eeprom.old_scl && !eeprom.scl) - { - if (eeprom.cycles < 9) - { - if ((eeprom.type.size_mask + 1) < (1 << (9 - eeprom.cycles))) - { - /* ignored bit (X24C01): slave mask should be right-shifted by one */ - eeprom.slave_mask >>= 1; - } - else - { - /* this is a WORD ADDRESS high bit */ - if (eeprom.old_sda) eeprom.word_address |= (1 << (8 - eeprom.cycles)); - else eeprom.word_address &= ~(1 << (8 - eeprom.cycles)); - } - - eeprom.cycles ++; - } - else - { - /* ACK CYCLE */ - eeprom.cycles = 1; - eeprom.word_address &= eeprom.type.size_mask; - eeprom.state = WRITE_DATA; - } - } - break; - - - /* - * Read Cycle - */ - case READ_DATA: - - Detect_START(); - Detect_STOP(); - - /* look for SCL HIGH to LOW transition */ - if (eeprom.old_scl && !eeprom.scl) - { - if (eeprom.cycles < 9) eeprom.cycles ++; - else - { - eeprom.cycles = 1; - - /* ACK not received */ - if (eeprom.old_sda) eeprom.state = WAIT_STOP; - } - } - break; - - - /* - * Write Cycle - */ - case WRITE_DATA: - - Detect_START(); - Detect_STOP(); - - /* look for SCL HIGH to LOW transition */ - if (eeprom.old_scl && !eeprom.scl) - { - if (eeprom.cycles < 9) - { - /* Write DATA bits (max 64kBytes) */ - uint16 sram_address = (eeprom.slave_mask | eeprom.word_address) & 0xFFFF; - if (eeprom.old_sda) sram.sram[sram_address] |= (1 << (8 - eeprom.cycles)); - else sram.sram[sram_address] &= ~(1 << (8 - eeprom.cycles)); - - if (eeprom.cycles == 8) - { - /* WORD ADDRESS is incremented (roll up at maximum pagesize) */ - eeprom.word_address = (eeprom.word_address & (0xFFFF - eeprom.type.pagewrite_mask)) | - ((eeprom.word_address + 1) & eeprom.type.pagewrite_mask); - } - - eeprom.cycles ++; - } - else eeprom.cycles = 1; /* ACK cycle */ - } - break; - } - - eeprom.old_scl = eeprom.scl; - eeprom.old_sda = eeprom.sda; -} - -unsigned int eeprom_read(int word_access) -{ - uint8 sda_out = eeprom.sda; - - /* EEPROM state */ - switch (eeprom.state) - { - case READ_DATA: - if (eeprom.cycles < 9) - { - /* Return DATA bits (max 64kBytes) */ - uint16 sram_address = (eeprom.slave_mask | eeprom.word_address) & 0xffff; - sda_out = (sram.sram[sram_address] >> (8 - eeprom.cycles)) & 1; - - if (eeprom.cycles == 8) - { - /* WORD ADDRESS is incremented (roll up at maximum array size) */ - eeprom.word_address ++; - eeprom.word_address &= eeprom.type.size_mask; - } - } - break; - - case GET_WORD_ADR_7BITS: - case GET_SLAVE_ADR: - case GET_WORD_ADR_HIGH: - case GET_WORD_ADR_LOW: - case WRITE_DATA: - if (eeprom.cycles == 9) sda_out = 0; - break; - - default: - break; - } - - /* memory access */ - if (word_access) - { - /* 16-bits access */ - if (eeprom.type.sda_out_adr & 1) return (sda_out << eeprom.type.sda_out_bit); /* LSB */ - else return (sda_out << (eeprom.type.sda_out_bit + 8)); /* MSB */ - } - else return (sda_out << eeprom.type.sda_out_bit); -} diff --git a/source/cart_hw/gg_eeprom.c b/source/cart_hw/gg_eeprom.c new file mode 100644 index 0000000..f3871b6 --- /dev/null +++ b/source/cart_hw/gg_eeprom.c @@ -0,0 +1,259 @@ +/**************************************************************************** + * Genesis Plus + * Microwire Serial EEPROM (93C46) support + * + * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#include "shared.h" + +#define BIT_DATA (0) +#define BIT_CLK (1) +#define BIT_CS (2) + + +T_EEPROM_93C gg_eeprom; + +void gg_eeprom_init() +{ + /* default eeprom state */ + memset(&gg_eeprom, 0, sizeof(T_EEPROM_93C)); + gg_eeprom.data = 1; + gg_eeprom.state = WAIT_START; +} + +void gg_eeprom_ctrl(unsigned char data) +{ + /* Reset EEPROM */ + if (data & 0x80) + { + gg_eeprom_init(); + return; + } + + /* Enable EEPROM */ + gg_eeprom.enabled = data & 0x08; +} + +void gg_eeprom_write(unsigned char data) +{ + /* Make sure CS is HIGH */ + if (data & (1 << BIT_CS)) + { + /* Data latched on CLK postive edge */ + if ((data & (1 << BIT_CLK)) && !gg_eeprom.clk) + { + /* Current EEPROM state */ + switch (gg_eeprom.state) + { + case WAIT_START: + { + /* Wait for START bit */ + if (data & (1 << BIT_DATA)) + { + gg_eeprom.opcode = 0; + gg_eeprom.cycles = 0; + gg_eeprom.state = GET_OPCODE; + } + break; + } + + case GET_OPCODE: + { + /* 8-bit buffer (opcode + address) */ + gg_eeprom.opcode |= ((data >> BIT_DATA) & 1) << (7 - gg_eeprom.cycles); + gg_eeprom.cycles++; + + if (gg_eeprom.cycles == 8) + { + /* Decode instruction */ + switch ((gg_eeprom.opcode >> 6) & 3) + { + case 1: + { + /* WRITE */ + gg_eeprom.buffer = 0; + gg_eeprom.cycles = 0; + gg_eeprom.state = WRITE_WORD; + break; + } + + case 2: + { + /* READ */ + gg_eeprom.buffer = *(uint16 *)(sram.sram + ((gg_eeprom.opcode & 0x3F) << 1)); + gg_eeprom.cycles = 0; + gg_eeprom.state = READ_WORD; + + /* Force DATA OUT */ + gg_eeprom.data = 0; + break; + } + + case 3: + { + /* ERASE */ + if (gg_eeprom.we) + { + *(uint16 *)(sram.sram + ((gg_eeprom.opcode & 0x3F) << 1)) = 0xFFFF; + } + + /* wait for next command */ + gg_eeprom.state = WAIT_STANDBY; + break; + } + + default: + { + /* special command */ + switch ((gg_eeprom.opcode >> 4) & 3) + { + case 1: + { + /* WRITE ALL */ + gg_eeprom.buffer = 0; + gg_eeprom.cycles = 0; + gg_eeprom.state = WRITE_WORD; + break; + } + + case 2: + { + /* ERASE ALL */ + if (gg_eeprom.we) + { + memset(sram.sram, 0xFF, 128); + } + + /* wait for next command */ + gg_eeprom.state = WAIT_STANDBY; + break; + } + + default: + { + /* WRITE ENABLE/DISABLE */ + gg_eeprom.we = (gg_eeprom.opcode >> 4) & 1; + + /* wait for next command */ + gg_eeprom.state = WAIT_STANDBY; + break; + } + } + break; + } + } + } + break; + } + + case WRITE_WORD: + { + /* 16-bit data buffer */ + gg_eeprom.buffer |= ((data >> BIT_DATA) & 1) << (15 - gg_eeprom.cycles); + gg_eeprom.cycles++; + + if (gg_eeprom.cycles == 16) + { + /* check EEPROM write protection */ + if (gg_eeprom.we) + { + if (gg_eeprom.opcode & 0x40) + { + /* write one word */ + *(uint16 *)(sram.sram + ((gg_eeprom.opcode & 0x3F) << 1)) = gg_eeprom.buffer; + } + else + { + /* write 64 words */ + int i; + for (i=0; i<64; i++) + { + *(uint16 *)(sram.sram + (i << 1)) = gg_eeprom.buffer; + + } + } + } + + /* wait for next command */ + gg_eeprom.state = WAIT_STANDBY; + } + break; + } + + case READ_WORD: + { + /* set DATA OUT */ + gg_eeprom.data = ((gg_eeprom.buffer >> (15 - gg_eeprom.cycles)) & 1); + gg_eeprom.cycles++; + + if (gg_eeprom.cycles == 16) + { + /* read next word (93C46B) */ + gg_eeprom.opcode++; + gg_eeprom.cycles = 0; + gg_eeprom.buffer = *(uint16 *)(sram.sram + ((gg_eeprom.opcode & 0x3F) << 1)); + } + break; + } + + default: + { + /* wait for STANDBY mode */ + break; + } + } + } + } + else + { + /* CS HIGH->LOW transition */ + if (gg_eeprom.cs) + { + /* standby mode */ + gg_eeprom.data = 1; + gg_eeprom.state = WAIT_START; + } + } + + /* Update input lines */ + gg_eeprom.cs = (data >> BIT_CS) & 1; + gg_eeprom.clk = (data >> BIT_CLK) & 1; +} + +unsigned char gg_eeprom_read(void) +{ + return ((gg_eeprom.cs << BIT_CS) | (gg_eeprom.data << BIT_DATA) | (1 << BIT_CLK)); +} + diff --git a/source/cart_hw/gg_eeprom.h b/source/cart_hw/gg_eeprom.h new file mode 100644 index 0000000..1e9a275 --- /dev/null +++ b/source/cart_hw/gg_eeprom.h @@ -0,0 +1,75 @@ +/**************************************************************************** + * Genesis Plus + * Microwire Serial EEPROM (93C46) support + * + * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#ifndef _GG_EEPROM_H_ +#define _GG_EEPROM_H_ + +typedef enum +{ + WAIT_STANDBY, + WAIT_START, + GET_OPCODE, + WRITE_WORD, + READ_WORD, + +} T_STATE; + +typedef struct +{ + uint8 enabled; /* 1: chip enabled */ + uint8 cs; /* CHIP SELECT line state */ + uint8 clk; /* CLK line state */ + uint8 data; /* DATA OUT line state */ + uint8 cycles; /* current operation cycle */ + uint8 we; /* 1: write enabled */ + uint8 opcode; /* 8-bit opcode + address */ + uint16 buffer; /* 16-bit data buffer */ + T_STATE state; /* current operation state */ + +} T_EEPROM_93C; + +/* global variables */ +extern T_EEPROM_93C gg_eeprom; + +/* Function prototypes */ +extern void gg_eeprom_init(); +extern void gg_eeprom_ctrl(unsigned char data); +extern void gg_eeprom_write(unsigned char data); +extern unsigned char gg_eeprom_read(void); + +#endif diff --git a/source/cart_hw/ggenie.c b/source/cart_hw/ggenie.c index 55a175f..43ce4ca 100644 --- a/source/cart_hw/ggenie.c +++ b/source/cart_hw/ggenie.c @@ -2,25 +2,42 @@ * Genesis Plus * Game Genie Hardware emulation * - * Copyright (C) 2009 Eke-Eke (GCN/Wii port) + * Copyright (C) 2009-2011 Eke-Eke (Genesis Plus GX) * * Based on documentation from Charles McDonald * (http://cgfm2.emuviews.com/txt/genie.txt) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 - ***************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" @@ -44,12 +61,17 @@ void ggenie_init(void) { memset(&ggenie,0,sizeof(ggenie)); - /* Open Game Genie ROM */ + /* Open Game Genie ROM file */ FILE *f = fopen(GG_ROM,"rb"); if (!f) return; - /* store Game Genie ROM above cartridge ROM + SRAM */ - if (cart.romsize > 0x600000) return; + /* Store Game Genie ROM above cartridge ROM + SRAM */ + if (cart.romsize > 0x600000) + { + fclose(f); + return; + } + ggenie.rom = cart.rom + 0x600000; /* Load ROM */ @@ -59,6 +81,8 @@ void ggenie_init(void) fread(ggenie.rom+i,0x1000,1,f); i += 0x1000; } + + /* Close ROM file */ fclose(f); #ifdef LSB_FIRST diff --git a/source/cart_hw/ggenie.h b/source/cart_hw/ggenie.h index cba8290..524c751 100644 --- a/source/cart_hw/ggenie.h +++ b/source/cart_hw/ggenie.h @@ -2,25 +2,42 @@ * Genesis Plus * Game Genie Hardware emulation * - * Copyright (C) 2009 Eke-Eke (GCN/Wii port) + * Copyright (C) 2009-2011 Eke-Eke (Genesis Plus GX) * * Based on documentation from Charles McDonald * (http://cgfm2.emuviews.com/txt/genie.txt) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 - ***************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _GGENIE_H_ #define _GGENIE_H_ diff --git a/source/cart_hw/md_cart.c b/source/cart_hw/md_cart.c index f2cd5d7..0f9c6f6 100644 --- a/source/cart_hw/md_cart.c +++ b/source/cart_hw/md_cart.c @@ -1,34 +1,50 @@ - /**************************************************************************** * Genesis Plus * Mega Drive cartridge hardware support * - * Copyright (C) 2007-2011 Eke-Eke (GCN/Wii port) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * Most cartridge protections documented by Haze + * Most cartridge protections were initially documented by Haze * (http://haze.mameworld.info/) * - * Realtec mapper documented by TascoDeluxe + * Realtec mapper was documented by TascoDeluxe * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 - ***************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "gamepad.h" -#define CART_CNT (44) +#define CART_CNT (48) /* Cart database entry */ typedef struct @@ -60,8 +76,10 @@ static uint32 default_regs_r(uint32 address); static uint32 default_regs_r_16(uint32 address); static void custom_regs_w(uint32 address, uint32 data); static void custom_alt_regs_w(uint32 address, uint32 data); -static uint32 topshooter_read(uint32 address); -static void topshooter_write(uint32 address, uint32 data); +static uint32 topshooter_r(uint32 address); +static void topshooter_w(uint32 address, uint32 data); +static uint32 sega_channel_r(uint32 address); +static void sega_channel_w(uint32 address, uint32 data); /* Games that need extra hardware emulation: - copy protection device @@ -81,10 +99,12 @@ static const T_CART_ENTRY rom_database[CART_CNT] = {0x4f10,0x0836,0x00,0x00,{{0x00,0x00,0x00,0x00},{0xffffff,0xffffff,0xffffff,0xffffff},{0x000000,0x000000,0x000000,0x000000},0,0,mapper_radica_r,NULL,NULL,NULL}}, /* RADICA (Volume 1) (byteswapped version) */ {0xf424,0x9f82,0x00,0x00,{{0x00,0x00,0x00,0x00},{0xffffff,0xffffff,0xffffff,0xffffff},{0x000000,0x000000,0x000000,0x000000},0,0,mapper_radica_r,NULL,NULL,NULL}}, -/* Chinese Fighters III */ +/* Tenchi wo Kurau III: Sangokushi Gaiden - Chinese Fighter */ {0x9490,0x8180,0x40,0x6f,{{0x00,0x00,0x00,0x00},{0xf0000c,0xf0000c,0xf0000c,0xf0000c},{0x400000,0x400004,0x400008,0x40000c},0,1,NULL,NULL,default_regs_r,custom_alt_regs_w}}, /* Top Fighter */ {0x4eb9,0x5d8b,0x60,0x7f,{{0x00,0x00,0x00,0x00},{0xf00007,0xf00007,0xf00007,0xffffff},{0x600001,0x600003,0x600005,0x000000},0,1,NULL,NULL,default_regs_r,custom_regs_w}}, +/* Soul Edge VS Samurai Spirits */ + {0x00ff,0x5d34,0x60,0x7f,{{0x00,0x00,0x00,0x00},{0xf00007,0xf00007,0xf00007,0xf00007},{0x600001,0x600003,0x600005,0x600007},0,1,NULL,NULL,default_regs_r,custom_regs_w}}, /* Mulan */ {0x0404,0x1b40,0x60,0x7f,{{0x00,0x00,0x00,0x00},{0xf00007,0xf00007,0xf00007,0xffffff},{0x600001,0x600003,0x600005,0x000000},0,1,NULL,NULL,default_regs_r,custom_regs_w}}, /* Pocket Monsters II */ @@ -99,6 +119,8 @@ static const T_CART_ENTRY rom_database[CART_CNT] = {0xffff,0x1d9b,0x40,0x40,{{0x00,0x00,0x00,0x00},{0xfffffd,0xfffffd,0xffffff,0xffffff},{0x400000,0x400004,0x000000,0x000000},0,0,NULL,NULL,default_regs_r,default_regs_w}}, /* Squirell King */ {0x0000,0x8ec8,0x40,0x40,{{0x00,0x00,0x00,0x00},{0xfffffd,0xfffffd,0xffffff,0xffffff},{0x400000,0x400004,0x000000,0x000000},0,0,NULL,NULL,default_regs_r,default_regs_w}}, +/* Tiny Toon Adventures 3 */ + {0x2020,0xed9c,0x40,0x40,{{0x00,0x00,0x00,0x00},{0xfffffd,0xfffffd,0xffffff,0xffffff},{0x400000,0x400004,0x000000,0x000000},0,0,NULL,NULL,default_regs_r,default_regs_w}}, /* Lian Huan Pao - Barver Battle Saga (registers accessed by Z80, related to sound engine ?) */ {0x30b9,0x1c2a,0x40,0x40,{{0x00,0x00,0x00,0x00},{0xfffffd,0xfffffd,0xffffff,0xffffff},{0x400000,0x400004,0x000000,0x000000},0,0,NULL,NULL,default_regs_r,default_regs_w}}, /* Shui Hu Zhuan (registers accessed by Z80, related to sound engine ?) */ @@ -121,12 +143,16 @@ static const T_CART_ENTRY rom_database[CART_CNT] = {0xfb40,0x4bed,0x40,0x40,{{0x00,0xaa,0x00,0xf0},{0xffffff,0xffffff,0xffffff,0xffffff},{0x000000,0x400002,0x000000,0x400006},0,0,NULL,NULL,default_regs_r_16,NULL}}, /* King of Fighter 98 */ {0x0000,0xd0a0,0x48,0x4f,{{0x00,0x00,0xaa,0xf0},{0xffffff,0xffffff,0xfc0000,0xfc0000},{0x000000,0x000000,0x480000,0x4c0000},0,0,NULL,NULL,default_regs_r,NULL}}, -/* Supper Bubble Bobble */ +/* Super Bubble Bobble */ {0x0000,0x16cd,0x40,0x40,{{0x55,0x0f,0x00,0x00},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x000000,0x000000},0,0,NULL,NULL,default_regs_r,NULL}}, +/* Tenchi wo Kurau II - The Battle of Red Cliffs (Unl) */ + {0x0000,0xed61,0x40,0x40,{{0x55,0x0f,0xaa,0xf0},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x400004,0x400006},0,0,NULL,NULL,default_regs_r,NULL}}, /* Huan Le Tao Qi Shu - Smart Mouse */ {0x0000,0x1a28,0x40,0x40,{{0x55,0x0f,0xaa,0xf0},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x400004,0x400006},0,0,NULL,NULL,default_regs_r,NULL}}, /* (*) Hei Tao 2 - Super Big 2 (patched ROM, unused registers) */ {0x0000,0x5843,0x40,0x40,{{0x55,0x0f,0xaa,0xf0},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x400004,0x400006},0,0,NULL,NULL,default_regs_r,NULL}}, +/* Mighty Morphin Power Rangers - The Fighting Edition */ + {0x0000,0x2288,0x40,0x40,{{0x55,0x0f,0xc9,0x18},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x400004,0x400006},0,0,NULL,NULL,default_regs_r,NULL}}, /* Elf Wor */ {0x0080,0x3dba,0x40,0x40,{{0x55,0x0f,0xc9,0x18},{0xffffff,0xffffff,0xffffff,0xffffff},{0x400000,0x400002,0x400004,0x400006},0,0,NULL,NULL,default_regs_r,NULL}}, /* Ya-Se Chuanshuo */ @@ -156,7 +182,7 @@ static const T_CART_ENTRY rom_database[CART_CNT] = /* Game no Kanzume Otokuyou */ {0x0000,0xf9d1,0x00,0x00,{{0x00,0x00,0x00,0x00},{0xffffff,0xffffff,0xffffff,0xffffff},{0x000000,0x000000,0x000000,0x000000},0,0,NULL,mapper_seganet_w,NULL,NULL}}, /* Top Shooter (arcade hardware) */ - {0xffff,0x3632,0x20,0x20,{{0x00,0x00,0x00,0x00},{0xffffff,0xffffff,0xffffff,0xffffff},{0x000000,0x000000,0x000000,0x000000},0,0,NULL,NULL,topshooter_read,topshooter_write}} + {0xffff,0x3632,0x20,0x20,{{0x00,0x00,0x00,0x00},{0xffffff,0xffffff,0xffffff,0xffffff},{0x000000,0x000000,0x000000,0x000000},0,0,NULL,NULL,topshooter_r,topshooter_w}} }; @@ -278,21 +304,21 @@ void md_cart_init(void) BACKUP MEMORY ***********************************************/ sram_init(); - eeprom_init(); + md_eeprom_init(); if (sram.on) { if (sram.custom) { /* Serial EEPROM */ - m68k_memory_map[eeprom.type.sda_out_adr >> 16].read8 = eeprom_read_byte; - m68k_memory_map[eeprom.type.sda_out_adr >> 16].read16 = eeprom_read_word; - m68k_memory_map[eeprom.type.sda_in_adr >> 16].read8 = eeprom_read_byte; - m68k_memory_map[eeprom.type.sda_in_adr >> 16].read16 = eeprom_read_word; - m68k_memory_map[eeprom.type.scl_adr >> 16].write8 = eeprom_write_byte; - m68k_memory_map[eeprom.type.scl_adr >> 16].write16 = eeprom_write_word; - zbank_memory_map[eeprom.type.sda_out_adr >> 16].read = eeprom_read_byte; - zbank_memory_map[eeprom.type.sda_in_adr >> 16].read = eeprom_read_byte; - zbank_memory_map[eeprom.type.scl_adr >> 16].write = eeprom_write_byte; + m68k_memory_map[md_eeprom.type.sda_out_adr >> 16].read8 = md_eeprom_read_byte; + m68k_memory_map[md_eeprom.type.sda_out_adr >> 16].read16 = md_eeprom_read_word; + m68k_memory_map[md_eeprom.type.sda_in_adr >> 16].read8 = md_eeprom_read_byte; + m68k_memory_map[md_eeprom.type.sda_in_adr >> 16].read16 = md_eeprom_read_word; + m68k_memory_map[md_eeprom.type.scl_adr >> 16].write8 = md_eeprom_write_byte; + m68k_memory_map[md_eeprom.type.scl_adr >> 16].write16 = md_eeprom_write_word; + zbank_memory_map[md_eeprom.type.sda_out_adr >> 16].read = md_eeprom_read_byte; + zbank_memory_map[md_eeprom.type.sda_in_adr >> 16].read = md_eeprom_read_byte; + zbank_memory_map[md_eeprom.type.scl_adr >> 16].write = md_eeprom_write_byte; } else { @@ -632,6 +658,13 @@ void md_cart_init(void) cart.hw.time_w = mapper_ssf2_w; } + /* Sega Channel mapped hardware (?) */ + if (strstr(rominfo.international,"Sega Channel") != NULL) + { + cart.hw.time_r = sega_channel_r; + cart.hw.time_w = sega_channel_w; + } + /* default write handler for !TIME range ($A130xx)*/ if (!cart.hw.time_w) { @@ -1120,7 +1153,9 @@ static void custom_alt_regs_w(uint32 address, uint32 data) default_regs_w(address, data); } -static uint32 topshooter_read(uint32 address) + +/* Top Shooter arcade board hardware */ +static uint32 topshooter_r(uint32 address) { if (address < 0x202000) { @@ -1174,12 +1209,58 @@ static uint32 topshooter_read(uint32 address) return READ_BYTE(sram.sram , address & 0xffff); } -static void topshooter_write(uint32 address, uint32 data) +static void topshooter_w(uint32 address, uint32 data) { if (address >= 0x202000) { WRITE_BYTE(sram.sram , address & 0xffff, data); return; } + m68k_unused_8_w(address, data); } + + +/* Sega Channel hardware (not emulated) */ +/* + +$A13004: BUSY ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? + +Unused read16 00A13004 (00005B54) +Unused read16 00A13004 (00005B70) +Unused read16 00A13006 (00005B7C) + +Unused read16 00A13004 (00005BC4) +Unused read16 00A13004 (00005BDA) + +Unused write16 00A13032 = 0004 (00005706) +Unused write16 00A130F0 = 0000 (0000570E) + +Unused write16 00A130F0 = 0000 (0000463E) +Unused write16 00A130F2 = 0001 (00004646) +Unused write16 00A130F4 = 0002 (0000464E) +Unused write16 00A130F6 = 0003 (00004656) +Unused write16 00A130F8 = 0004 (0000465E) +Unused write16 00A130FA = 0005 (00004666) + +Unused write16 00A13032 = 0004 (00005706) +Unused write16 00A13032 = 0104 (0000579E) + +Unused write16 00380000 = ACDC (00005718) +Unused write16 00380002 = 0000 (00005722) +Unused read16 00380000 (0000572C) +Unused write16 00A13032 = 0104 (0000579E) +Unused write16 00300000 = ACDC (000057B2) +Unused write16 00380000 = 0000 (000057BC) +Unused read16 00300000 (000057C6) + +*/ +static uint32 sega_channel_r(uint32 address) +{ + return m68k_read_bus_16(address);; +} + +static void sega_channel_w(uint32 address, uint32 data) +{ + m68k_unused_16_w(address, data); +} diff --git a/source/cart_hw/md_cart.h b/source/cart_hw/md_cart.h index 425c97f..68ebdbd 100644 --- a/source/cart_hw/md_cart.h +++ b/source/cart_hw/md_cart.h @@ -2,27 +2,44 @@ * Genesis Plus * Mega Drive cartridge hardware support * - * Copyright (C) 2007-2011 Eke-Eke (GCN/Wii port) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * Lots of protection mechanism have been discovered by Haze + * Most cartridge protections were initially documented by Haze * (http://haze.mameworld.info/) * - * Realtec mapper has been figured out by TascoDeluxe + * Realtec mapper was documented by TascoDeluxe * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 - ***************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _MD_CART_H_ #define _MD_CART_H_ @@ -32,9 +49,9 @@ #define TYPE_AR 0x02 /* (Pro) Action Replay */ #define TYPE_SK 0x03 /* Sonic & Knuckles */ -/* Special hardware (0x01 reserved for SMS 3-D glasses) */ -#define HW_J_CART 0x02 -#define HW_LOCK_ON 0x04 +/* Special hardware (0x01 & 0x02 reserved for Master System 3-D glasses & Terebi Oekaki) */ +#define HW_J_CART 0x04 +#define HW_LOCK_ON 0x08 /* Cartridge extra hardware */ typedef struct diff --git a/source/cart_hw/md_eeprom.c b/source/cart_hw/md_eeprom.c new file mode 100644 index 0000000..d799dfc --- /dev/null +++ b/source/cart_hw/md_eeprom.c @@ -0,0 +1,554 @@ +/**************************************************************************** + * Genesis Plus + * I2C Serial EEPROM (24Cxx) support + * + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#include "shared.h" + +#define GAME_CNT 30 + +T_EEPROM_24C md_eeprom; + +typedef struct +{ + char game_id[16]; + uint16 chk; + T_EEPROM_TYPE type; +} T_GAME_ENTRY; + +static const T_GAME_ENTRY database[GAME_CNT] = +{ + /* ACCLAIM mappers */ + /* 24C02 (old mapper) */ + {{"T-081326" }, 0, {8, 0xFF, 0xFF, 0x200001, 0x200001, 0x200001, 0, 1, 1}}, /* NBA Jam (UE) */ + {{"T-81033" }, 0, {8, 0xFF, 0xFF, 0x200001, 0x200001, 0x200001, 0, 1, 1}}, /* NBA Jam (J) */ + /* 24C02 */ + {{"T-081276" }, 0, {8, 0xFF, 0xFF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* NFL Quarterback Club */ + /* 24C04 */ + {{"T-81406" }, 0, {8, 0x1FF, 0x1FF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* NBA Jam TE */ + /* 24C16 */ + {{"T-081586" }, 0, {8, 0x7FF, 0x7FF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* NFL Quarterback Club '96 */ + /* 24C65 */ + {{"T-81576" }, 0, {16, 0x1FFF, 0x1FFF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* College Slam */ + {{"T-81476" }, 0, {16, 0x1FFF, 0x1FFF, 0x200001, 0x200001, 0x200000, 0, 0, 0}}, /* Frank Thomas Big Hurt Baseball */ + + /* EA mapper (24C01 only) */ + {{"T-50176" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* Rings of Power */ + {{"T-50396" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* NHLPA Hockey 93 */ + {{"T-50446" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* John Madden Football 93 */ + {{"T-50516" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* John Madden Football 93 (Championship Ed.) */ + {{"T-50606" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 7, 7, 6}}, /* Bill Walsh College Football */ + + /* SEGA mapper (24C01 only) */ + {{"T-12046" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Megaman - The Wily Wars */ + {{"T-12053" }, 0xEA80, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Rockman Mega World (J) [A] */ + {{"MK-1215" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Evander 'Real Deal' Holyfield's Boxing */ + {{"MK-1228" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Greatest Heavyweights of the Ring (U) */ + {{"G-5538" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Greatest Heavyweights of the Ring (J) */ + {{"PR-1993" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Greatest Heavyweights of the Ring (E) */ + {{"G-4060" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Wonderboy in Monster World */ + {{"00001211-00"}, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Sports Talk Baseball */ + {{"00004076-00"}, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Honoo no Toukyuuji Dodge Danpei */ + {{"G-4524" }, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Ninja Burai Densetsu */ + {{"00054503-00"}, 0, {7, 0x7F, 0x7F, 0x200001, 0x200001, 0x200001, 0, 0, 1}}, /* Game Toshokan */ + + /* CODEMASTERS mapper */ + /* 24C08 */ + {{"T-120106" }, 0, {8, 0x3FF, 0x3FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Brian Lara Cricket */ + {{"00000000-00"}, 0x168B, {8, 0x3FF, 0x3FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines Military */ + {{"00000000-00"}, 0xCEE0, {8, 0x3FF, 0x3FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines Military (Bad)*/ + /* 24C16 */ + {{"T-120096" }, 0, {8, 0x7FF, 0x7FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines 2 - Turbo Tournament (E) */ + {{"00000000-00"}, 0x165E, {8, 0x7FF, 0x7FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines Turbo Tournament 96 */ + {{"00000000-00"}, 0x2C41, {8, 0x7FF, 0x7FF, 0x300000, 0x380001, 0x300000, 0, 7, 1}}, /* Micro Machines Turbo Tournament 96 (Bad)*/ + /* 24C65 */ + {{"T-120146-50"}, 0, {16, 0x1FFF, 0x1FFF, 0x300000, 0x380001, 0x300000, 0, 7, 1}} /* Brian Lara Cricket 96, Shane Warne Cricket */ +}; + + +static void eeprom_update(void); +static unsigned char eeprom_out(void); + +void md_eeprom_init() +{ + int i = 0; + + /* initialize eeprom */ + memset(&md_eeprom, 0, sizeof(T_EEPROM_24C)); + md_eeprom.sda = md_eeprom.old_sda = 1; + md_eeprom.scl = md_eeprom.old_scl = 1; + md_eeprom.state = STAND_BY; + + /* no eeprom by default */ + sram.custom = 0; + + /* look into game database */ + while (i> md_eeprom.type.sda_in_bit) & 1; + do_update = 1; + } + + if (address == md_eeprom.type.scl_adr) + { + md_eeprom.scl = (data >> md_eeprom.type.scl_bit) & 1; + do_update = 1; + } + + if (do_update) + { + eeprom_update(); + return; + } + + m68k_unused_8_w(address, data); +} + +void md_eeprom_write_word(unsigned int address, unsigned int data) +{ + int do_update = 0; + + if (address == md_eeprom.type.sda_in_adr) + { + md_eeprom.sda = (data >> (8 + md_eeprom.type.sda_in_bit)) & 1; + do_update = 1; + } + else if (address == (md_eeprom.type.sda_in_adr ^1)) + { + md_eeprom.sda = (data >> md_eeprom.type.sda_in_bit) & 1; + do_update = 1; + } + + if (address == md_eeprom.type.scl_adr) + { + md_eeprom.scl = (data >> (8 + md_eeprom.type.scl_bit)) & 1; + do_update = 1; + } + else if (address == (md_eeprom.type.scl_adr ^1)) + { + md_eeprom.scl = (data >> md_eeprom.type.scl_bit) & 1; + do_update = 1; + } + + if (do_update) + { + eeprom_update(); + return; + } + + m68k_unused_16_w(address, data); +} + + +static inline void Detect_START() +{ + if (md_eeprom.old_scl && md_eeprom.scl) + { + if (md_eeprom.old_sda && !md_eeprom.sda) + { + md_eeprom.cycles = 0; + md_eeprom.slave_mask = 0; + if (md_eeprom.type.address_bits == 7) + { + md_eeprom.word_address = 0; + md_eeprom.state = GET_WORD_ADR_7BITS; + } + else md_eeprom.state = GET_SLAVE_ADR; + } + } +} + +static inline void Detect_STOP() +{ + if (md_eeprom.old_scl && md_eeprom.scl) + { + if (!md_eeprom.old_sda && md_eeprom.sda) + { + md_eeprom.state = STAND_BY; + } + } +} + +static void eeprom_update(void) +{ + /* EEPROM current state */ + switch (md_eeprom.state) + { + /* Standby Mode */ + case STAND_BY: + { + Detect_START(); + Detect_STOP(); + break; + } + + /* Suspended Mode */ + case WAIT_STOP: + { + Detect_STOP(); + break; + } + + /* Get Word Address 7 bits: MODE-1 only (24C01) + * and R/W bit + */ + case GET_WORD_ADR_7BITS: + { + Detect_START(); + Detect_STOP(); + + /* look for SCL LOW to HIGH transition */ + if (!md_eeprom.old_scl && md_eeprom.scl) + { + if (md_eeprom.cycles == 0) md_eeprom.cycles ++; + } + + + /* look for SCL HIGH to LOW transition */ + if (md_eeprom.old_scl && !md_eeprom.scl && (md_eeprom.cycles > 0)) + { + if (md_eeprom.cycles < 8) + { + md_eeprom.word_address |= (md_eeprom.old_sda << (7 - md_eeprom.cycles)); + } + else if (md_eeprom.cycles == 8) + { + md_eeprom.rw = md_eeprom.old_sda; + } + else + { /* ACK CYCLE */ + md_eeprom.cycles = 0; + md_eeprom.word_address &= md_eeprom.type.size_mask; + md_eeprom.state = md_eeprom.rw ? READ_DATA : WRITE_DATA; + } + + md_eeprom.cycles ++; + } + break; + } + + /* Get Slave Address (3bits) : MODE-2 & MODE-3 only (24C01 - 24C512) (0-3bits, depending on the array size) + * or/and Word Address MSB: MODE-2 only (24C04 - 24C16) (0-3bits, depending on the array size) + * and R/W bit + */ + case GET_SLAVE_ADR: + { + Detect_START(); + Detect_STOP(); + + /* look for SCL LOW to HIGH transition */ + if (!md_eeprom.old_scl && md_eeprom.scl) + { + if (md_eeprom.cycles == 0) md_eeprom.cycles ++; + } + + /* look for SCL HIGH to LOW transition */ + if (md_eeprom.old_scl && !md_eeprom.scl && (md_eeprom.cycles > 0)) + { + if ((md_eeprom.cycles > 4) && (md_eeprom.cycles <8)) + { + if ((md_eeprom.type.address_bits == 16) || + (md_eeprom.type.size_mask < (1 << (15 - md_eeprom.cycles)))) + { + /* this is a SLAVE ADDRESS bit */ + md_eeprom.slave_mask |= (md_eeprom.old_sda << (7 - md_eeprom.cycles)); + } + else + { + /* this is a WORD ADDRESS high bit */ + if (md_eeprom.old_sda) md_eeprom.word_address |= (1 << (15 - md_eeprom.cycles)); + else md_eeprom.word_address &= ~(1 << (15 - md_eeprom.cycles)); + } + } + else if (md_eeprom.cycles == 8) md_eeprom.rw = md_eeprom.old_sda; + else if (md_eeprom.cycles > 8) + { + /* ACK CYCLE */ + md_eeprom.cycles = 0; + if (md_eeprom.type.address_bits == 16) + { + /* two ADDRESS bytes */ + md_eeprom.state = md_eeprom.rw ? READ_DATA : GET_WORD_ADR_HIGH; + md_eeprom.slave_mask <<= 16; + } + else + { + /* one ADDRESS byte */ + md_eeprom.state = md_eeprom.rw ? READ_DATA : GET_WORD_ADR_LOW; + md_eeprom.slave_mask <<= 8; + } + } + + md_eeprom.cycles ++; + } + break; + } + + /* Get Word Address MSB (4-8bits depending on the array size) + * MODE-3 only (24C32 - 24C512) + */ + case GET_WORD_ADR_HIGH: + { + Detect_START(); + Detect_STOP(); + + /* look for SCL HIGH to LOW transition */ + if (md_eeprom.old_scl && !md_eeprom.scl) + { + if (md_eeprom.cycles < 9) + { + if ((md_eeprom.type.size_mask + 1) < (1 << (17 - md_eeprom.cycles))) + { + /* ignored bit: slave mask should be right-shifted by one */ + md_eeprom.slave_mask >>= 1; + } + else + { + /* this is a WORD ADDRESS high bit */ + if (md_eeprom.old_sda) md_eeprom.word_address |= (1 << (16 - md_eeprom.cycles)); + else md_eeprom.word_address &= ~(1 << (16 - md_eeprom.cycles)); + } + + md_eeprom.cycles ++; + } + else + { + /* ACK CYCLE */ + md_eeprom.cycles = 1; + md_eeprom.state = GET_WORD_ADR_LOW; + } + } + break; + } + + /* Get Word Address LSB: 7bits (24C01) or 8bits (24C02-24C512) + * MODE-2 and MODE-3 only (24C01 - 24C512) + */ + case GET_WORD_ADR_LOW: + { + Detect_START(); + Detect_STOP(); + + /* look for SCL HIGH to LOW transition */ + if (md_eeprom.old_scl && !md_eeprom.scl) + { + if (md_eeprom.cycles < 9) + { + if ((md_eeprom.type.size_mask + 1) < (1 << (9 - md_eeprom.cycles))) + { + /* ignored bit (X24C01): slave mask should be right-shifted by one */ + md_eeprom.slave_mask >>= 1; + } + else + { + /* this is a WORD ADDRESS high bit */ + if (md_eeprom.old_sda) md_eeprom.word_address |= (1 << (8 - md_eeprom.cycles)); + else md_eeprom.word_address &= ~(1 << (8 - md_eeprom.cycles)); + } + + md_eeprom.cycles ++; + } + else + { + /* ACK CYCLE */ + md_eeprom.cycles = 1; + md_eeprom.word_address &= md_eeprom.type.size_mask; + md_eeprom.state = WRITE_DATA; + } + } + break; + } + + /* + * Read Cycle + */ + case READ_DATA: + { + Detect_START(); + Detect_STOP(); + + /* look for SCL HIGH to LOW transition */ + if (md_eeprom.old_scl && !md_eeprom.scl) + { + if (md_eeprom.cycles < 9) md_eeprom.cycles ++; + else + { + md_eeprom.cycles = 1; + + /* ACK not received */ + if (md_eeprom.old_sda) md_eeprom.state = WAIT_STOP; + } + } + break; + } + + /* + * Write Cycle + */ + case WRITE_DATA: + { + Detect_START(); + Detect_STOP(); + + /* look for SCL HIGH to LOW transition */ + if (md_eeprom.old_scl && !md_eeprom.scl) + { + if (md_eeprom.cycles < 9) + { + /* Write DATA bits (max 64kBytes) */ + uint16 sram_address = (md_eeprom.slave_mask | md_eeprom.word_address) & 0xFFFF; + if (md_eeprom.old_sda) sram.sram[sram_address] |= (1 << (8 - md_eeprom.cycles)); + else sram.sram[sram_address] &= ~(1 << (8 - md_eeprom.cycles)); + + if (md_eeprom.cycles == 8) + { + /* WORD ADDRESS is incremented (roll up at maximum pagesize) */ + md_eeprom.word_address = (md_eeprom.word_address & (0xFFFF - md_eeprom.type.pagewrite_mask)) | + ((md_eeprom.word_address + 1) & md_eeprom.type.pagewrite_mask); + } + + md_eeprom.cycles ++; + } + else md_eeprom.cycles = 1; /* ACK cycle */ + } + break; + } + } + + md_eeprom.old_scl = md_eeprom.scl; + md_eeprom.old_sda = md_eeprom.sda; +} + +static unsigned char eeprom_out(void) +{ + uint8 sda_out = md_eeprom.sda; + + /* EEPROM state */ + switch (md_eeprom.state) + { + case READ_DATA: + { + if (md_eeprom.cycles < 9) + { + /* Return DATA bits (max 64kBytes) */ + uint16 sram_address = (md_eeprom.slave_mask | md_eeprom.word_address) & 0xffff; + sda_out = (sram.sram[sram_address] >> (8 - md_eeprom.cycles)) & 1; + + if (md_eeprom.cycles == 8) + { + /* WORD ADDRESS is incremented (roll up at maximum array size) */ + md_eeprom.word_address ++; + md_eeprom.word_address &= md_eeprom.type.size_mask; + } + } + break; + } + + case GET_WORD_ADR_7BITS: + case GET_SLAVE_ADR: + case GET_WORD_ADR_HIGH: + case GET_WORD_ADR_LOW: + case WRITE_DATA: + { + if (md_eeprom.cycles == 9) sda_out = 0; + break; + } + + default: + { + break; + } + } + + return (sda_out << md_eeprom.type.sda_out_bit); +} diff --git a/source/cart_hw/eeprom.h b/source/cart_hw/md_eeprom.h similarity index 53% rename from source/cart_hw/eeprom.h rename to source/cart_hw/md_eeprom.h index bc20290..e1c489e 100644 --- a/source/cart_hw/eeprom.h +++ b/source/cart_hw/md_eeprom.h @@ -1,26 +1,43 @@ /**************************************************************************** * Genesis Plus - * I2C EEPROM support + * I2C Serial EEPROM (24Cxx) support * - * Copyright (C) 2007, 2008, 2009 Eke-Eke (GCN/Wii port) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 - ***************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ -#ifndef _EEPROM_H_ -#define _EEPROM_H_ +#ifndef _MD_EEPROM_H_ +#define _MD_EEPROM_H_ typedef enum { @@ -79,14 +96,16 @@ typedef struct T_EEPROM_STATE state; /* current operation state */ T_EEPROM_TYPE type; /* EEPROM characteristics for this game */ -} T_EEPROM; +} T_EEPROM_24C; /* global variables */ -extern T_EEPROM eeprom; +extern T_EEPROM_24C md_eeprom; /* Function prototypes */ -extern void eeprom_init(); -extern void eeprom_write(unsigned int address, unsigned int data, int word_access); -extern unsigned int eeprom_read(int word_access); +extern void md_eeprom_init(); +extern unsigned int md_eeprom_read_byte(unsigned int address); +extern unsigned int md_eeprom_read_word(unsigned int address); +extern void md_eeprom_write_byte(unsigned int address, unsigned int data); +extern void md_eeprom_write_word(unsigned int address, unsigned int data); #endif diff --git a/source/cart_hw/sms_cart.c b/source/cart_hw/sms_cart.c index e2c2144..6f8a851 100644 --- a/source/cart_hw/sms_cart.c +++ b/source/cart_hw/sms_cart.c @@ -1,48 +1,66 @@ - /**************************************************************************** * Genesis Plus - * Master System cartridge hardware support + * SG-1000, Master System & Game Gear cartridge hardware support * - * - * Copyright (C) 1998-2007 Charles MacDonald (SMS Plus original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * Most cartridge protections documented by Haze - * (http://haze.mameworld.info/) + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * Realtec mapper documented by TascoDeluxe + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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. + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - * 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. + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. * - * 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 - ***************************************************************************/ + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" +#include "terebi_oekaki.h" +#ifdef NGC +#include "cheats.h" +#endif -#define MAPPER_NONE (0) -#define MAPPER_SEGA (1) -#define MAPPER_CODIES (2) -#define MAPPER_KOREA (3) -#define MAPPER_MSX (4) +#define MAPPER_TEREBI (0) +#define MAPPER_NONE (1) +#define MAPPER_SEGA (2) +#define MAPPER_SEGA_X (3) +#define MAPPER_CODIES (4) +#define MAPPER_KOREA (5) +#define MAPPER_MSX (6) +#define MAPPER_93C46 (7) -#define GAME_DATABASE_CNT (75) +#define GAME_DATABASE_CNT (183) typedef struct { uint32 crc; - uint8 glasses_3d; + uint8 g_3d; + uint8 fm; uint8 peripheral; uint8 mapper; + uint8 system; uint8 region; } rominfo_t; @@ -52,105 +70,229 @@ static struct uint8 mapper; } slot; -/* SMS game database */ static const rominfo_t game_list[GAME_DATABASE_CNT] = { - /* games requiring CODEMASTER mapper (NOTE: extended video modes don't work on Genesis VDP !) */ - {0x29822980, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_EUROPE}, /* Cosmic Spacehead */ - {0xA577CE46, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_EUROPE}, /* Micro Machines */ - {0xF7C524F6, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_EUROPE}, /* Micro Machines [BAD DUMP] */ - {0xDBE8895C, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_EUROPE}, /* Micro Machines 2 - Turbo Tournament */ - {0xC1756BEE, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_EUROPE}, /* Pete Sampras Tennis */ - {0x8813514B, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_EUROPE}, /* Excellent Dizzy Collection, The [Proto] */ - {0xEA5C3A6F, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_USA}, /* Dinobasher - Starring Bignose the Caveman [Proto] */ - {0x152F0DCC, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_USA}, /* Drop Zone" */ - {0xAA140C9C, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_USA}, /* Excellent Dizzy Collection, The [SMS-GG] */ - {0xB9664AE1, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_USA}, /* Fantastic Dizzy */ - {0xC888222B, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_USA}, /* Fantastic Dizzy [SMS-GG] */ - {0x76C5BDFB, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_USA}, /* Jang Pung 2 [SMS-GG] */ - {0xD9A7F170, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, REGION_USA}, /* Man Overboard! */ + /* games requiring Mega Drive VDP (Mode 5) */ + {0x47FA618D, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_PBC, REGION_USA}, /* Charles MacDonald's Mode 5 Demo Program */ - /* games requiring KOREA mappers (NOTE: TMS9918 video modes don't work on Genesis VDP !) */ - {0x17AB6883, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, REGION_JAPAN_NTSC}, /* FA Tetris (KR) */ - {0x61E8806F, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, REGION_JAPAN_NTSC}, /* Flash Point (KR) */ - {0x445525E2, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, REGION_JAPAN_NTSC}, /* Penguin Adventure (KR) */ - {0x83F0EEDE, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, REGION_JAPAN_NTSC}, /* Street Master (KR) */ - {0xA05258F5, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, REGION_JAPAN_NTSC}, /* Won-Si-In (KR) */ - {0x06965ED9, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, REGION_JAPAN_NTSC}, /* F-1 Spirit - The way to Formula-1 (KR) */ - {0x89B79E77, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, REGION_JAPAN_NTSC}, /* Dodgeball King (KR) */ - {0x18FB98A3, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, REGION_JAPAN_NTSC}, /* Jang Pung 3 (KR) */ - {0x97D03541, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, REGION_JAPAN_NTSC}, /* Sangokushi 3 (KR)"} */ - {0x67C2F0FF, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, REGION_JAPAN_NTSC}, /* Super Boy 2 (KR) */ + /* games requiring 315-5124 VDP (Mark-III, Master System I) */ + {0x32759751, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS, REGION_JAPAN_NTSC}, /* Y's (J) */ + + /* games requiring Sega 315-5235 mapper without bank shifting */ + {0x23BAC434, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA_X, SYSTEM_GG, REGION_USA}, /* Shining Force Gaiden - Final Conflict (JP) [T-Eng] */ + + /* games using Korean mappers */ + {0x17AB6883, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* FA Tetris (KR) */ + {0x61E8806F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Flash Point (KR) */ + {0x445525E2, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Penguin Adventure (KR) */ + {0x83F0EEDE, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Street Master (KR) */ + {0xA05258F5, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Won-Si-In (KR) */ + {0x06965ED9, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* F-1 Spirit - The way to Formula-1 (KR) */ + {0x77EFE84A, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_MSX, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Cyborg Z (KR) */ + {0x89B79E77, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Dodgeball King (KR) */ + {0x18FB98A3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Jang Pung 3 (KR) */ + {0x97D03541, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Sangokushi 3 (KR)"} */ + {0x67C2F0FF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_KOREA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Super Boy 2 (KR) */ + + /* games using Codemaster mapper */ + {0x29822980, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_EUROPE}, /* Cosmic Spacehead */ + {0x8813514B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_EUROPE}, /* Excellent Dizzy Collection, The [Proto] */ + {0xB9664AE1, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_EUROPE}, /* Fantastic Dizzy */ + {0xA577CE46, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_EUROPE}, /* Micro Machines */ + {0xEA5C3A6F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_SMS2, REGION_USA}, /* Dinobasher - Starring Bignose the Caveman [Proto] */ + {0xAA140C9C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Excellent Dizzy Collection, The [SMS-GG] */ + {0xC888222B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Fantastic Dizzy [SMS-GG] */ + {0x76C5BDFB, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GGMS, REGION_USA}, /* Jang Pung 2 [SMS-GG] */ + {0x6CAA625B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Cosmic Spacehead [GG]*/ + {0x152F0DCC, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Drop Zone" */ + {0x5E53C7F7, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Ernie Els Golf */ + {0xD9A7F170, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Man Overboard! */ + {0xF7C524F6, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Micro Machines [GG] */ + {0xDBE8895C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Micro Machines 2 - Turbo Tournament */ + {0xC1756BEE, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_CODIES, SYSTEM_GG, REGION_USA}, /* Pete Sampras Tennis */ + + /* games using Serial EEPROM */ + {0x36EBCD6D, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_93C46, SYSTEM_GG, REGION_USA}, /* Majors Pro Baseball */ + {0x3D8D0DD6, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_93C46, SYSTEM_GG, REGION_USA}, /* World Series Baseball [v0] */ + {0xBB38CFD7, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_93C46, SYSTEM_GG, REGION_USA}, /* World Series Baseball [v1] */ + {0x578A8A38, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_93C46, SYSTEM_GG, REGION_USA}, /* World Series Baseball '95 */ + + /* games using Terebi Oekaki graphic board */ + {0xDD4A661B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_TEREBI, SYSTEM_SG, REGION_JAPAN_NTSC}, /* Terebi Oekaki */ + + /* games requiring JAPANESE region setting */ + {0x71DEBA5A, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GG, REGION_JAPAN_NTSC}, /* Pop Breaker */ + + /* games requiring Mark-III hardware (no Memory Control port) */ + {0xBD1CC7DF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_MARKIII, REGION_USA}, /* Super Tetris (K) */ /* games requiring PAL timings */ - {0x72420F38, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Addams Familly */ - {0x2D48C1D3, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Back to the Future Part III */ - {0x1CBB7BF1, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Battlemaniacs (BR) */ - {0x1B10A951, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Bram Stoker's Dracula */ - {0xC0E25D62, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* California Games II */ - {0x45C50294, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Jogos de Verao II (BR) */ - {0xC9DBF936, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Home Alone */ - {0x0047B615, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Predator2 */ - {0xF42E145C, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Quest for the Shaven Yak Starring Ren Hoek & Stimpy (BR) */ - {0x9F951756, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* RoboCop 3 */ - {0xF8176918, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Sensible Soccer */ - {0x1575581D, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Shadow of the Beast */ - {0x96B3F29E, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Sonic Blast (BR) */ - {0x5B3B922C, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Sonic the Hedgehog 2 [V0] */ - {0xD6F2BFCA, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Sonic the Hedgehog 2 [V1] */ - {0xCA1D3752, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Space Harrier [50 Hz] */ - {0x85CFC9C9, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_EUROPE}, /* Taito Chase H.Q. */ + {0x72420F38, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Addams Familly */ + {0x2D48C1D3, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Back to the Future Part III */ + {0x1CBB7BF1, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Battlemaniacs (BR) */ + {0x1B10A951, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Bram Stoker's Dracula */ + {0xC0E25D62, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* California Games II */ + {0x45C50294, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Jogos de Verao II (BR) */ + {0xC9DBF936, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Home Alone */ + {0x0047B615, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Predator2 */ + {0xF42E145C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Quest for the Shaven Yak Starring Ren Hoek & Stimpy (BR) */ + {0x9F951756, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* RoboCop 3 */ + {0xF8176918, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Sensible Soccer */ + {0x1575581D, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Shadow of the Beast */ + {0x96B3F29E, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Sonic Blast (BR) */ + {0x5B3B922C, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Sonic the Hedgehog 2 [V0] */ + {0xD6F2BFCA, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Sonic the Hedgehog 2 [V1] */ + {0xCA1D3752, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Space Harrier [50 Hz] */ + {0x85CFC9C9, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_EUROPE}, /* Taito Chase H.Q. */ + + /* games running in Game Gear MS compatibility mode */ + {0x59840FD6, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Castle of Illusion - Starring Mickey Mouse [SMS-GG] */ + {0x9C76FB3A, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Rastan Saga [SMS-GG] */ + {0xC8381DEF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Taito Chase H.Q [SMS-GG] */ + {0xDA8E95A9, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* WWF Wrestlemania Steel Cage Challenge [SMS-GG] */ + {0x1D93246E, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Olympic Gold [A][SMS-GG] */ + {0xA2F9C7AF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Olympic Gold [B][SMS-GG] */ + {0x01EAB89D, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Out Run Europa [SMS-GG] */ + {0xF037EC00, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Out Run Europa (US) [SMS-GG] */ + {0xE5F789B9, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Predator 2 [SMS-GG] */ + {0x311D2863, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Prince of Persia [A][SMS-GG] */ + {0x45F058D6, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Prince of Persia [B][SMS-GG] */ + {0x56201996, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* R.C. Grand Prix [SMS-GG] */ + {0x10DBBEF4, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_USA}, /* Super Kick Off [SMS-GG] */ + {0xBD1CC7DF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_JAPAN_NTSC}, /* Super Tetris (KR) [SMS-GG] */ + {0x9942B69B, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_JAPAN_NTSC}, /* Castle of Illusion - Starring Mickey Mouse (J) [SMS-GG] */ + {0x7BB81E3D, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_JAPAN_NTSC}, /* Taito Chase H.Q (J) [SMS-GG] */ + {0x6F8E46CF, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_JAPAN_NTSC}, /* Alex Kidd in Miracle World (TW) [SMS-GG] */ + {0x3382D73F, 0, 0, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_GGMS, REGION_JAPAN_NTSC}, /* Olympic Gold (TW) [SMS-GG] */ /* games requiring 3-D Glasses */ - {0x871562b0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_JAPAN_NTSC}, /* Maze Walker */ - {0x156948f9, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_JAPAN_NTSC}, /* Space Harrier 3-D (J) */ - {0x6BD5C2BF, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Space Harrier 3-D */ - {0x8ECD201C, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Blade Eagle 3-D */ - {0xFBF96C81, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Blade Eagle 3-D (BR) */ - {0x58D5FC48, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Blade Eagle 3-D [Proto] */ - {0x31B8040B, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Maze Hunter 3-D */ - {0xABD48AD2, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Poseidon Wars 3-D */ - {0xA3EF13CB, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Zaxxon 3-D */ - {0xBBA74147, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Zaxxon 3-D [Proto] */ - {0xD6F43DDA, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, REGION_USA}, /* Out Run 3-D */ + {0x6BD5C2BF, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Space Harrier 3-D */ + {0x8ECD201C, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Blade Eagle 3-D */ + {0xFBF96C81, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Blade Eagle 3-D (BR) */ + {0x58D5FC48, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Blade Eagle 3-D [Proto] */ + {0x31B8040B, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Maze Hunter 3-D */ + {0xABD48AD2, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Poseidon Wars 3-D */ + {0xA3EF13CB, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Zaxxon 3-D */ + {0xBBA74147, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Zaxxon 3-D [Proto] */ + {0xD6F43DDA, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Out Run 3-D */ + {0x871562b0, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Maze Walker */ + {0x156948f9, 1, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Space Harrier 3-D (J) */ /* games requiring 3-D Glasses & Sega Light Phaser */ - {0xFBE5CFBB, 1, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Missile Defense 3D */ - {0xE79BB689, 1, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Missile Defense 3D [BIOS] */ + {0xFBE5CFBB, 1, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Missile Defense 3D */ + {0xE79BB689, 1, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Missile Defense 3D [BIOS] */ /* games requiring Sega Light Phaser */ - {0x861B6E79, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Assault City [Light Phaser] */ - {0x5FC74D2A, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Gangster Town */ - {0xE167A561, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Hang-On / Safari Hunt */ - {0xC5083000, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Hang-On / Safari Hunt [BAD DUMP] */ - {0x91E93385, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Hang-On / Safari Hunt [BIOS] */ - {0xE8EA842C, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Marksman Shooting / Trap Shooting */ - {0xE8215C2E, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Marksman Shooting / Trap Shooting / Safari Hunt */ - {0x205CAAE8, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Operation Wolf (can be played with gamepad in port B)*/ - {0x23283F37, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Operation Wolf [A] (can be played with gamepad in port B) */ - {0xDA5A7013, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Rambo 3 */ - {0x79AC8E7F, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Rescue Mission */ - {0x4B051022, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Shooting Gallery */ - {0xA908CFF5, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Spacegun */ - {0x5359762D, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Wanted */ - {0x0CA95637, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, REGION_USA}, /* Laser Ghost */ + {0x861B6E79, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Assault City [Light Phaser] */ + {0x5FC74D2A, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Gangster Town */ + {0xE167A561, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Hang-On / Safari Hunt */ + {0x91E93385, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Hang-On / Safari Hunt [BIOS] */ + {0xE8EA842C, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Marksman Shooting / Trap Shooting */ + {0xE8215C2E, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Marksman Shooting / Trap Shooting / Safari Hunt */ + {0x205CAAE8, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Operation Wolf */ + {0x23283F37, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Operation Wolf [A] */ + {0xDA5A7013, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Rambo 3 */ + {0x79AC8E7F, 0, 1, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Rescue Mission */ + {0x4B051022, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Shooting Gallery */ + {0xA908CFF5, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Spacegun */ + {0x5359762D, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Wanted */ + {0x0CA95637, 0, 0, SYSTEM_LIGHTPHASER, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Laser Ghost */ /* games requiring Sega Paddle */ - {0xF9DBB533, 0, SYSTEM_PADDLE, MAPPER_SEGA, REGION_JAPAN_NTSC}, /* Alex Kidd BMX Trial */ - {0xA6FA42D0, 0, SYSTEM_PADDLE, MAPPER_SEGA, REGION_JAPAN_NTSC}, /* Galactic Protector */ - {0x29BC7FAD, 0, SYSTEM_PADDLE, MAPPER_SEGA, REGION_JAPAN_NTSC}, /* Megumi Rescue */ - {0x315917D4, 0, SYSTEM_PADDLE, MAPPER_SEGA, REGION_JAPAN_NTSC}, /* Woody Pop */ + {0xF9DBB533, 0, 1, SYSTEM_PADDLE, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Alex Kidd BMX Trial */ + {0xA6FA42D0, 0, 1, SYSTEM_PADDLE, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Galactic Protector */ + {0x29BC7FAD, 0, 1, SYSTEM_PADDLE, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Megumi Rescue */ + {0x315917D4, 0, 0, SYSTEM_PADDLE, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Woody Pop */ - /* games requiring Sega Sport Pad */ - {0x0CB7E21F, 0, SYSTEM_SPORTSPAD, MAPPER_SEGA, REGION_USA}, /* Great Ice Hockey */ - {0xE42E4998, 0, SYSTEM_SPORTSPAD, MAPPER_SEGA, REGION_USA}, /* Sports Pad Football */ - {0x41C948BF, 0, SYSTEM_SPORTSPAD, MAPPER_SEGA, REGION_USA} /* Sports Pad Soccer */ + /* games requiring Sega Sport Pad */ + {0x0CB7E21F, 0, 0, SYSTEM_SPORTSPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Great Ice Hockey */ + {0xE42E4998, 0, 0, SYSTEM_SPORTSPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Sports Pad Football */ + {0x41C948BF, 0, 0, SYSTEM_SPORTSPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Sports Pad Soccer */ + + /* games supporting YM2413 FM */ + {0x1C951F8E, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* After Burner */ + {0xC13896D5, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Alex Kidd: The Lost Stars */ + {0x5CBFE997, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Alien Syndrome */ + {0xBBA2FE98, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Altered Beast */ + {0xFF614EB3, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Aztec Adventure */ + {0x3084CF11, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Bomber Raid */ + {0xAC6009A7, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* California Games */ + {0xA4852757, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Captain Silver */ + {0xB81F6FA5, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Captain Silver (U) */ + {0x3CFF6E80, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Casino Games */ + {0xE7F62E6D, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Cloud Master */ + {0x908E7524, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Cyborg Hunter */ + {0xA55D89F3, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Double Dragon */ + {0xB8B141F9, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Fantasy Zone II */ + {0xD29889AD, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Fantasy Zone: The Maze */ + {0xA4AC35D8, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Galaxy Force */ + {0x6C827520, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Galaxy Force (U) */ + {0x1890F407, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Game Box Série Esportes Radicais (BR) */ + {0xB746A6F5, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Global Defense */ + {0x91A0FC4E, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Global Defense [Proto] */ + {0x48651325, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Golfamania */ + {0x5DABFDC3, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Golfamania [Proto] */ + {0xA51376FE, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Golvellius - Valley of Doom */ + {0x98E4AE4A, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Great Golf */ + {0x516ED32E, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Kenseiden */ + {0xE8511B08, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Lord of The Sword */ + {0x0E333B6E, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Miracle Warriors - Seal of The Dark Lord */ + {0x301A59AA, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Miracle Warriors - Seal of The Dark Lord [Proto] */ + {0x01D67C0B, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Mônica no Castelo do Dragão (BR) */ + {0x5589D8D2, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Out Run */ + {0xE030E66C, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Parlour Games */ + {0xF97E9875, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Penguin Land */ + {0x4077EFD9, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Power Strike */ + {0xBB54B6B0, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* R-Type */ + {0x42FC47EE, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Rampage */ + {0xC547EB1B, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Rastan */ + {0x9A8B28EC, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Scramble Spirits */ + {0xAAB67EC3, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Shanghai */ + {0x0C6FAC4E, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Shinobi */ + {0x4752CAE7, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* SpellCaster */ + {0x1A390B93, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Tennis Ace */ + {0xAE920E4B, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Thunder Blade */ + {0x51BD14BE, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Time Soldiers */ + {0x22CCA9BB, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Turma da Mônica em: O Resgate (BR) */ + {0xB52D60C8, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Ultima IV */ + {0xDE9F8517, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Ultima IV [Proto] */ + {0xDFB0B161, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Vigilante */ + {0x679E1676, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Wonder Boy III: The Dragon's Trap */ + {0x8CBEF0C1, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Wonder Boy in Monster Land */ + {0x2F2E3BC9, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_USA}, /* Zillion II - The Tri Formation */ + {0x48D44A13, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_NONE, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Master System Bios (J) */ + {0xD8C4165B, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Aleste */ + {0x4CC11DF9, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Alien Syndrome (J) */ + {0xE421E466, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Chouon Senshi Borgman */ + {0x2BCDB8FA, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Doki Doki Penguin Land - Uchuu-Daibouken */ + {0x56BD2455, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Doki Doki Penguin Land - Uchuu-Daibouken [Proto] */ + {0xC722FB42, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Fantasy Zone II (J) */ + {0x7ABC70E9, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Family Games (Party Games) */ + {0x6586BD1F, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Masters Golf */ + {0x4847BC91, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Masters Golf [Proto] */ + {0xB9FDF6D9, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Haja no Fuuin */ + {0x955A009E, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Hoshi wo Sagashite */ + {0x05EA5353, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Kenseiden (J) */ + {0xD11D32E4, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Kujakuou */ + {0xAA7D6F45, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Lord of Sword */ + {0xBF0411AD, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Maou Golvellius */ + {0x21A21352, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Maou Golvellius [Proto] */ + {0x5B5F9106, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Nekyuu Kousien */ + {0xBEA27D5C, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Opa Opa */ + {0x6605D36A, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Phantasy Star (J) */ + {0xE1FFF1BB, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Shinobi (J) */ + {0x11645549, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Solomon no Kagi - Oujo Rihita no Namida */ + {0x7E0EF8CB, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Super Racing */ + {0xB1DA6A30, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Super Wonder Boy Monster World */ + {0x8132AB2C, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Tensai Bakabon */ + {0xC0CE19B1, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_SMS2, REGION_JAPAN_NTSC}, /* Thunder Blade (J) */ + {0x07301F83, 0, 1, SYSTEM_MS_GAMEPAD, MAPPER_SEGA, SYSTEM_PBC, REGION_JAPAN_NTSC} /* Phantasy Star [Megadrive] (J) */ }; /* 1K trash buffer */ static uint8 dummy[0x400]; -/* Function prorotypes */ +/* Function prototypes */ static void mapper_8k_w(int offset, unsigned int data); static void mapper_16k_w(int offset, unsigned int data); static void write_mapper_none(unsigned int address, unsigned char data); @@ -158,58 +300,106 @@ static void write_mapper_sega(unsigned int address, unsigned char data); static void write_mapper_codies(unsigned int address, unsigned char data); static void write_mapper_korea(unsigned int address, unsigned char data); static void write_mapper_msx(unsigned int address, unsigned char data); - +static void write_mapper_93c46(unsigned int address, unsigned char data); +static void write_mapper_terebi(unsigned int address, unsigned char data); +static unsigned char read_mapper_93c46(unsigned int address); +static unsigned char read_mapper_terebi(unsigned int address); +static unsigned char read_mapper_default(unsigned int address); void sms_cart_init(void) { /* default mapper */ - slot.mapper = MAPPER_SEGA; + slot.mapper = (cart.romsize > 0xC000) ? MAPPER_SEGA : MAPPER_NONE; - /* default supported peripheral */ + /* use Master System controller by default */ uint8 device = SYSTEM_MS_GAMEPAD; + + /* disable 3-D Glasses by default */ cart.special = 0; + /* disable YM2413 chip disabled by default in AUTO mode */ + if (config.ym2413 & 2) + { + config.ym2413 = 2; + } + /* compute CRC */ uint32 crc = crc32(0, cart.rom, cart.romsize); - /* detect cartridge mapper */ + /* auto-detect game settings */ int i; for (i=0; i 0x8000) { - z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x07) << 10]; + for(i = 0x20; i < 0x30; i++) + { + z80_readmap[i] = &cart.rom[i << 10]; + z80_writemap[i] = dummy; + } + } + else + { + for(i = 0x20; i < 0x30; i++) + { + z80_readmap[i] = z80_writemap[i] = &sram.sram[(i & 0x0F) << 10]; + } + } + + if (system_hw == SYSTEM_SG) + { + /* $C000-$FFFF mapped to internal RAM (2K mirrored) */ + for(i = 0x30; i < 0x40; i++) + { + z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x01) << 10]; + } + } + else + { + /* $C000-$FFFF mapped to internal RAM (8K mirrored) */ + for(i = 0x30; i < 0x40; i++) + { + z80_readmap[i] = z80_writemap[i] = &work_ram[(i & 0x07) << 10]; + } } /* Reset cartridge paging registers */ switch(slot.mapper) { - case MAPPER_NONE: case MAPPER_SEGA: + case MAPPER_SEGA_X: { slot.fcr[0] = 0; slot.fcr[1] = 0; @@ -289,30 +508,31 @@ void sms_cart_reset(void) } } + /* Set default memory map */ - if (slot.mapper != MAPPER_MSX) - { - mapper_16k_w(0,slot.fcr[0]); - mapper_16k_w(1,slot.fcr[1]); - mapper_16k_w(2,slot.fcr[2]); - mapper_16k_w(3,slot.fcr[3]); - } - else + if (slot.mapper == MAPPER_MSX) { mapper_8k_w(0,slot.fcr[0]); mapper_8k_w(1,slot.fcr[1]); mapper_8k_w(2,slot.fcr[2]); mapper_8k_w(3,slot.fcr[3]); } + else if (slot.mapper > MAPPER_NONE) + { + mapper_16k_w(0,slot.fcr[0]); + mapper_16k_w(1,slot.fcr[1]); + mapper_16k_w(2,slot.fcr[2]); + mapper_16k_w(3,slot.fcr[3]); + } } - void sms_cart_switch(int enabled) - { +void sms_cart_switch(int enabled) +{ int i; if (enabled) { - /* Enable cartdige ROM at $0000-$BFFF */ + /* Enable cartridge ROM at $0000-$BFFF */ for(i = 0x00; i < 0x30; i++) { z80_readmap[i] = &cart.rom[(i & 0x1F) << 10]; @@ -340,6 +560,12 @@ int sms_cart_region_detect(void) { if (crc == game_list[i].crc) { + /* Turma da Mônica em: O Resgate & Wonder Boy III enable FM support on japanese hardware only */ + if (config.ym2413 && ((crc == 0x22CCA9BB) || (crc == 0x679E1676))) + { + return REGION_JAPAN_NTSC; + } + return game_list[i].region; } } @@ -361,20 +587,20 @@ int sms_cart_context_load(uint8 *state) load_param(slot.fcr, sizeof(slot.fcr)); /* Set default memory map */ - if (slot.mapper != MAPPER_MSX) - { - mapper_16k_w(0,slot.fcr[0]); - mapper_16k_w(1,slot.fcr[1]); - mapper_16k_w(2,slot.fcr[2]); - mapper_16k_w(3,slot.fcr[3]); - } - else + if (slot.mapper == MAPPER_MSX) { mapper_8k_w(0,slot.fcr[0]); mapper_8k_w(1,slot.fcr[1]); mapper_8k_w(2,slot.fcr[2]); mapper_8k_w(3,slot.fcr[3]); } + else if (slot.mapper > MAPPER_NONE) + { + mapper_16k_w(0,slot.fcr[0]); + mapper_16k_w(1,slot.fcr[1]); + mapper_16k_w(2,slot.fcr[2]); + mapper_16k_w(3,slot.fcr[3]); + } return bufferptr; } @@ -429,6 +655,11 @@ void mapper_8k_w(int offset, unsigned int data) break; } } + +#ifdef NGC + /* update ROM patches */ + ROMCheatUpdate(); +#endif } void mapper_16k_w(int offset, unsigned int data) @@ -439,7 +670,7 @@ void mapper_16k_w(int offset, unsigned int data) uint8 page = data % (cart.romsize >> 14); /* page index increment (SEGA mapper) */ - if (slot.fcr[0] & 0x03) + if ((slot.fcr[0] & 0x03) && (slot.mapper == MAPPER_SEGA)) { page = (page + ((4 - (slot.fcr[0] & 0x03)) << 3)) % (cart.romsize >> 14); } @@ -454,7 +685,7 @@ void mapper_16k_w(int offset, unsigned int data) if(data & 0x08) { /* external RAM (upper or lower 16K) mapped at $8000-$BFFF */ - for(i = 0x20; i <= 0x2F; i++) + for(i = 0x20; i < 0x30; i++) { z80_readmap[i] = z80_writemap[i] = &sram.sram[((data & 0x04) << 12) + ((i & 0x0F) << 10)]; } @@ -465,7 +696,7 @@ void mapper_16k_w(int offset, unsigned int data) page = slot.fcr[3] % (cart.romsize >> 14); /* page index increment (SEGA mapper) */ - if (data & 0x03) + if ((data & 0x03) && (slot.mapper == MAPPER_SEGA)) { page = (page + ((4 - (data & 0x03)) << 3)) % (cart.romsize >> 14); } @@ -568,6 +799,11 @@ void mapper_16k_w(int offset, unsigned int data) break; } } + +#ifdef NGC + /* update ROM patches */ + ROMCheatUpdate(); +#endif } static void write_mapper_none(unsigned int address, unsigned char data) @@ -629,3 +865,65 @@ static void write_mapper_msx(unsigned int address, unsigned char data) z80_writemap[address >> 10][address & 0x03FF] = data; } + +static void write_mapper_93c46(unsigned int address, unsigned char data) +{ + if ((address == 0x8000) && gg_eeprom.enabled) + { + gg_eeprom_write(data); + return; + } + + if (address == 0xFFFC) + { + gg_eeprom_ctrl(data); + } + + if(address > 0xFFFC) + { + mapper_16k_w(address & 3, data); + } + + z80_writemap[address >> 10][address & 0x03FF] = data; +} + +static void write_mapper_terebi(unsigned int address, unsigned char data) +{ + if (address == 0x6000) + { + terebi_oekaki_write(data); + return; + } + + z80_writemap[address >> 10][address & 0x03FF] = data; +} + +static unsigned char read_mapper_93c46(unsigned int address) +{ + if ((address == 0x8000) && gg_eeprom.enabled) + { + return gg_eeprom_read(); + } + + return z80_readmap[address >> 10][address & 0x03FF]; +} + +static unsigned char read_mapper_terebi(unsigned int address) +{ + if (address == 0x8000) + { + return (terebi_oekaki_read() >> 8); + } + + if (address == 0xA000) + { + return (terebi_oekaki_read() & 0xFF); + } + + return z80_readmap[address >> 10][address & 0x03FF]; +} + +static unsigned char read_mapper_default(unsigned int address) +{ + return z80_readmap[address >> 10][address & 0x03FF]; +} diff --git a/source/cart_hw/sms_cart.h b/source/cart_hw/sms_cart.h index 615f3c4..8bb30d4 100644 --- a/source/cart_hw/sms_cart.h +++ b/source/cart_hw/sms_cart.h @@ -1,30 +1,47 @@ /**************************************************************************** * Genesis Plus - * Master System cartridge hardware support + * SG-1000, Master System & Game Gear cartridge hardware support * - * Copyright (C) 1998-2007 Charles MacDonald (SMS Plus original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * Realtec mapper has been figured out by TascoDeluxe + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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. + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - * 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 - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _SMS_CART_H_ #define _SMS_CART_H_ +/* Special hardware (0x01 reserved for Master System 3-D glasses) */ +#define HW_TEREBI_OEKAKI 0x02 + /* Function prototypes */ extern void sms_cart_init(void); extern void sms_cart_reset(void); diff --git a/source/cart_hw/sram.c b/source/cart_hw/sram.c index 61cad85..500c659 100644 --- a/source/cart_hw/sram.c +++ b/source/cart_hw/sram.c @@ -2,21 +2,37 @@ * Genesis Plus * Backup RAM support * - * Copyright (C) 2007, 2008, 2009 Eke-Eke (GCN/Wii port) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -48,7 +64,7 @@ void sram_init() sram.sram = cart.rom + 0x500000; /* initialize SRAM */ - memset(sram.sram, 0xff, 0x10000); + memset(sram.sram, 0xFF, 0x10000); sram.crc = crc32(0, sram.sram, 0x10000); /* retrieve informations from header */ diff --git a/source/cart_hw/sram.h b/source/cart_hw/sram.h index daf6118..bae3ab5 100644 --- a/source/cart_hw/sram.h +++ b/source/cart_hw/sram.h @@ -2,21 +2,37 @@ * Genesis Plus * Backup RAM support * - * Copyright (C) 2007, 2008, 2009 Eke-Eke (GCN/Wii port) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/cart_hw/svp/ssp16.c b/source/cart_hw/svp/ssp16.c index 349d636..6ab1d37 100644 --- a/source/cart_hw/svp/ssp16.c +++ b/source/cart_hw/svp/ssp16.c @@ -461,7 +461,9 @@ static u32 pm_io(int reg, int write, u32 d) #ifdef LOG_SVP elprintf(EL_SVP, "PM%i (%c) set to %08x @ %04x", reg, write ? 'w' : 'r', rPMC.v, GET_PPC_OFFS()); #endif - ssp->pmac_read[write ? reg + 6 : reg] = rPMC.v; + + unsigned int *pmac = &ssp->pmac_read[reg]; + pmac[6*write] = rPMC.v; ssp->emu_status &= ~SSP_PMC_SET; #ifdef LOG_SVP if ((rPMC.v & 0x7f) == 0x1c && (rPMC.v & 0x7fff0000) == 0) { @@ -582,7 +584,8 @@ static u32 pm_io(int reg, int write, u32 d) } // PMC value corresponds to last PMR accessed (not sure). - rPMC.v = ssp->pmac_read[write ? reg + 6 : reg]; + unsigned int *pmac = &ssp->pmac_read[reg]; + rPMC.v = pmac[6*write]; return d; } @@ -1089,7 +1092,7 @@ void ssp1601_run(int cycles) SET_PC(rPC); g_cycles = cycles; - while (g_cycles > 0 && !(ssp->emu_status & SSP_WAIT_MASK)) + do { int op; u32 tmpv; @@ -1317,8 +1320,8 @@ void ssp1601_run(int cycles) #endif break; } - g_cycles--; } + while (--g_cycles > 0 && !(ssp->emu_status & SSP_WAIT_MASK)); read_P(); // update P rPC = GET_PC(); diff --git a/source/genesis.c b/source/genesis.c index 6b6da95..19e4adb 100644 --- a/source/genesis.c +++ b/source/genesis.c @@ -2,22 +2,40 @@ * Genesis Plus * Internal Hardware & Bus controllers * + * Support for SG-1000, Mark-III, Master System, Game Gear & Mega Drive hardware + * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -43,17 +61,30 @@ void gen_init(void) int i; /* initialize 68k */ - m68k_set_cpu_type(M68K_CPU_TYPE_68000); m68k_init(); /* initialize Z80 */ z80_init(0,z80_irq_callback); - /* initialize 68k memory map */ - /* $000000-$7FFFFF is affected to cartridge area (see md_cart.c) */ - for (i=0x80; i<0x100; i++) + /* initialize default 68k memory map */ + + /* $000000-$7FFFFF : cartridge area (md_cart.c) */ + + /* $800000-$DFFFFF : illegal access by default */ + for (i=0x80; i<0xe0; i++) + { + m68k_memory_map[i].base = work_ram; /* for VDP DMA */ + m68k_memory_map[i].read8 = m68k_lockup_r_8; + m68k_memory_map[i].read16 = m68k_lockup_r_16; + m68k_memory_map[i].write8 = m68k_lockup_w_8; + m68k_memory_map[i].write16 = m68k_lockup_w_16; + zbank_memory_map[i].read = zbank_lockup_r; + zbank_memory_map[i].write = zbank_lockup_w; + } + + /* $E00000-$FFFFFF : Work RAM */ + for (i=0xe0; i<0x100; i++) { - /* $800000-$FFFFFF is affected to WRAM (see VDP DMA) */ m68k_memory_map[i].base = work_ram; m68k_memory_map[i].read8 = NULL; m68k_memory_map[i].read16 = NULL; @@ -63,18 +94,6 @@ void gen_init(void) zbank_memory_map[i].write = NULL; } - /* initialize 68k memory handlers */ - for (i=0x80; i<0xe0; i++) - { - /* $800000-$DFFFFF : illegal area by default */ - m68k_memory_map[i].read8 = m68k_lockup_r_8; - m68k_memory_map[i].read16 = m68k_lockup_r_16; - m68k_memory_map[i].write8 = m68k_lockup_w_8; - m68k_memory_map[i].write16 = m68k_lockup_w_16; - zbank_memory_map[i].read = zbank_lockup_r; - zbank_memory_map[i].write = zbank_lockup_w; - } - /* $A10000-$A1FFFF : I/O & Control registers */ m68k_memory_map[0xa1].read8 = ctrl_io_read_byte; m68k_memory_map[0xa1].read16 = ctrl_io_read_word; @@ -94,48 +113,9 @@ void gen_init(void) zbank_memory_map[i].write = zbank_write_vdp; } - /* MS COMPATIBILITY mode */ - if (system_hw == SYSTEM_PBC) + /* 68k mode */ + if (system_hw == SYSTEM_MD) { - /* initialize Z80 read handler */ - /* NB: memory map & write handler are defined by cartridge hardware */ - z80_readmem = z80_sms_memory_r; - - /* initialize Z80 ports handlers */ - z80_writeport = z80_sms_port_w; - z80_readport = z80_sms_port_r; - - /* initialize MS cartridge hardware */ - sms_cart_init(); - } - else - { - /* PICO hardware */ - if (system_hw == SYSTEM_PICO) - { - /* additional registers mapped to $800000-$80FFFF */ - m68k_memory_map[0x80].read8 = pico_read_byte; - m68k_memory_map[0x80].read16 = pico_read_word; - m68k_memory_map[0x80].write8 = m68k_unused_8_w; - m68k_memory_map[0x80].write16 = m68k_unused_16_w; - - /* there is no I/O area (Notaz) */ - m68k_memory_map[0xa1].read8 = m68k_read_bus_8; - m68k_memory_map[0xa1].read16 = m68k_read_bus_16; - m68k_memory_map[0xa1].write8 = m68k_unused_8_w; - m68k_memory_map[0xa1].write16 = m68k_unused_16_w; - - /* page registers */ - pico_current = 0x00; - pico_page[0] = 0x00; - pico_page[1] = 0x01; - pico_page[2] = 0x03; - pico_page[3] = 0x07; - pico_page[4] = 0x0F; - pico_page[5] = 0x1F; - pico_page[6] = 0x3F; - } - /* initialize Z80 memory map */ /* $0000-$3FFF is mapped to Z80 RAM (8K mirrored) */ /* $4000-$FFFF is mapped to hardware but Z80.PC should never point there */ @@ -145,8 +125,8 @@ void gen_init(void) } /* initialize Z80 memory handlers */ - z80_writemem = z80_md_memory_w; - z80_readmem = z80_md_memory_r; + z80_writemem = z80_memory_w; + z80_readmem = z80_memory_r; /* initialize Z80 port handlers */ z80_writeport = z80_unused_port_w; @@ -155,6 +135,83 @@ void gen_init(void) /* initialize MD cartridge hardware */ md_cart_init(); } + + /* PICO hardware */ + else if (system_hw == SYSTEM_PICO) + { + /* additional registers mapped to $800000-$80FFFF */ + m68k_memory_map[0x80].read8 = pico_read_byte; + m68k_memory_map[0x80].read16 = pico_read_word; + m68k_memory_map[0x80].write8 = m68k_unused_8_w; + m68k_memory_map[0x80].write16 = m68k_unused_16_w; + + /* there is no I/O area (Notaz) */ + m68k_memory_map[0xa1].read8 = m68k_read_bus_8; + m68k_memory_map[0xa1].read16 = m68k_read_bus_16; + m68k_memory_map[0xa1].write8 = m68k_unused_8_w; + m68k_memory_map[0xa1].write16 = m68k_unused_16_w; + + /* page registers */ + pico_current = 0x00; + pico_page[0] = 0x00; + pico_page[1] = 0x01; + pico_page[2] = 0x03; + pico_page[3] = 0x07; + pico_page[4] = 0x0F; + pico_page[5] = 0x1F; + pico_page[6] = 0x3F; + + /* initialize cartridge hardware */ + md_cart_init(); + } + + /* Z80 mode */ + else + { + /* initialize cartridge hardware (memory handlers are also initialized) */ + sms_cart_init(); + + /* initialize Z80 ports handlers */ + switch (system_hw) + { + case SYSTEM_PBC: + { + z80_writeport = z80_md_port_w; + z80_readport = z80_md_port_r; + break; + } + + case SYSTEM_GG: + case SYSTEM_GGMS: + { + z80_writeport = z80_gg_port_w; + z80_readport = z80_gg_port_r; + break; + } + + case SYSTEM_SMS: + case SYSTEM_SMS2: + { + z80_writeport = z80_ms_port_w; + z80_readport = z80_ms_port_r; + break; + } + + case SYSTEM_MARKIII: + { + z80_writeport = z80_m3_port_w; + z80_readport = z80_m3_port_r; + break; + } + + case SYSTEM_SG: + { + z80_writeport = z80_sg_port_w; + z80_readport = z80_sg_port_r; + break; + } + } + } } void gen_reset(int hard_reset) @@ -175,20 +232,9 @@ void gen_reset(int hard_reset) /* 68k & Z80 could restart anywhere in VDP frame (Bonkers, Eternal Champions, X-Men 2) */ mcycles_68k = mcycles_z80 = (uint32)((MCYCLES_PER_LINE * lines_per_frame) * ((double)rand() / (double)RAND_MAX)); - if (system_hw == SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { - /* reset MS cartridge hardware */ - sms_cart_reset(); - - /* Z80 is running */ - zstate = 1; - - /* 68k is halted */ - m68k_pulse_halt(); - } - else - { - /* reset MD cartridge hardware */ + /* reset cartridge hardware */ md_cart_reset(hard_reset); /* Z80 bus is released & Z80 is reseted */ @@ -233,6 +279,20 @@ void gen_reset(int hard_reset) /* reset 68k */ m68k_pulse_reset(); } + else + { + /* Z80 cycles should a multiple of 15 to avoid rounding errors */ + mcycles_z80 = (mcycles_z80 / 15) * 15; + + /* reset cartridge hardware */ + sms_cart_reset(); + + /* Z80 is running */ + zstate = 1; + + /* 68k is halted (/VRES is forced low) */ + m68k_pulse_halt(); + } /* reset Z80 */ z80_reset(); diff --git a/source/genesis.h b/source/genesis.h index 081a80a..c099713 100644 --- a/source/genesis.h +++ b/source/genesis.h @@ -2,22 +2,40 @@ * Genesis Plus * Internal hardware & Bus controllers * + * Support for SG-1000, Mark-III, Master System, Game Gear & Mega Drive hardware + * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/gx/aram.c b/source/gx/aram.c deleted file mode 100644 index d18114c..0000000 --- a/source/gx/aram.c +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** - * aram.c - * - * ARAM wrapper for libogc - * - * Softdev (2006) - * - * 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 - * - ***************************************************************************/ - -#include "shared.h" - -#define ARAMSTART 0x8000 -#define ARAM_READ 1 -#define ARAM_WRITE 0 - -/** - * StartARAM - * This simply sets up the call to internal libOGC. - * Passing NULL for array list, and 0 items to allocate. - * Required so libOGC knows to handle any interrupts etc. - */ -void StartARAM () -{ - AR_Init (NULL, 0); -} - -/** - * ARAMPut - * - * Move data from MAIN memory to ARAM - */ -void ARAMPut (char *src, char *dst, int len) -{ - DCFlushRange (src, len); - AR_StartDMA( ARAM_WRITE, (u32)src, (u32)dst, len); - while (AR_GetDMAStatus()); -} - -/** - * ARAMFetch - * - * This function will move data from ARAM to MAIN memory - */ -void -ARAMFetch (char *dst, char *src, int len) -{ - DCInvalidateRange(dst, len); - AR_StartDMA( ARAM_READ, (u32) dst, (u32) src, len); - while (AR_GetDMAStatus()); -} diff --git a/source/gx/aram.h b/source/gx/aram.h deleted file mode 100644 index fea61cb..0000000 --- a/source/gx/aram.h +++ /dev/null @@ -1,31 +0,0 @@ -/**************************************************************************** - * aram.c - * - * ARAM wrapper for libogc - * - * Softdev (2006) - * - * 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 - * - ***************************************************************************/ - -#ifndef _ARAM_H -#define _ARAM_H - -extern void StartARAM (); -extern void ARAMFetch (char *src, char *dst, int len); -extern void ARAMPut (char *src, char *dst, int len); - -#endif diff --git a/source/gx/config.c b/source/gx/config.c index 60344b4..705dedd 100644 --- a/source/gx/config.c +++ b/source/gx/config.c @@ -3,23 +3,40 @@ * * Genesis Plus GX configuration file support * - * Eke-Eke (2008) + * Copyright Eke-Eke (2007-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + #include "shared.h" #include "gui.h" #include "menu.h" @@ -76,19 +93,20 @@ void config_default(void) config.fm_preamp = 100; config.hq_fm = 1; config.psgBoostNoise = 0; - config.filter = 1; + config.filter = 0; config.lp_range = 50; config.low_freq = 880; config.high_freq = 5000; config.lg = 1.0; config.mg = 1.0; config.hg = 1.0; - config.rolloff = 0.995; + config.rolloff = 0.990; config.dac_bits = 14; - config.ym2413_enabled = 1; + config.ym2413 = 2; /* AUTO */ /* system options */ - config.region_detect = 0; + config.system = 0; /* AUTO */ + config.region_detect = 0; /* AUTO */ config.force_dtack = 0; config.addr_error = 1; config.tmss = 0; @@ -102,27 +120,22 @@ void config_default(void) config.xscale = 0; config.yscale = 0; config.aspect = 1; - config.overscan = 3; + config.overscan = 3; /* FULL */ config.ntsc = 0; if (VIDEO_HaveComponentCable()) { config.render = 2; config.bilinear = 1; -#ifdef HW_RVL - config.trap = 1; -#endif } else { config.render = 0; config.bilinear = 0; -#ifdef HW_RVL - config.trap = 0; -#endif } #ifdef HW_RVL - config.gamma = VI_GM_1_0 / 10.0; + config.trap = 0; + config.gamma = VI_GM_1_0 / 10.0; #endif /* controllers options */ diff --git a/source/gx/config.h b/source/gx/config.h index 899af92..e5abd85 100644 --- a/source/gx/config.h +++ b/source/gx/config.h @@ -3,28 +3,44 @@ * * Genesis Plus GX configuration file support * - * Eke-Eke (2008) + * Copyright Eke-Eke (2007-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _CONFIG_H_ #define _CONFIG_H_ -#define CONFIG_VERSION "GENPLUS-GX 1.5.1" +#define CONFIG_VERSION "GENPLUS-GX 1.6.0" /**************************************************************************** * Config Option @@ -37,7 +53,7 @@ typedef struct uint8 filter; uint8 psgBoostNoise; uint8 dac_bits; - uint8 ym2413_enabled; + uint8 ym2413; int16 psg_preamp; int16 fm_preamp; int16 lp_range; @@ -47,6 +63,7 @@ typedef struct int16 mg; int16 hg; float rolloff; + uint8 system; uint8 region_detect; uint8 force_dtack; uint8 addr_error; diff --git a/source/gx/fileio/file_load.c b/source/gx/fileio/file_load.c index f083c1c..8894482 100644 --- a/source/gx/fileio/file_load.c +++ b/source/gx/fileio/file_load.c @@ -3,30 +3,46 @@ * * ROM File loading support * - * Eke-Eke (2010) + * Copyright Eke-Eke (2008-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ********************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "file_load.h" #include "gui.h" #include "history.h" -#include "unzip.h" #include "filesel.h" +#include "file_slot.h" #include #ifdef HW_RVL @@ -97,7 +113,7 @@ static int MountDVD(void) } /*************************************************************************** - * FileSortCallback (code by Marty Disibio) + * FileSortCallback (thanks to Marty Disibio) * * Quick sort callback to sort file entries with the following order: * . @@ -117,12 +133,22 @@ static int FileSortCallback(const void *f1, const void *f2) } /* If one is a file and one is a directory the directory is first. */ - if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1; - if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1; + if(((FILEENTRIES *)f1)->flags && !((FILEENTRIES *)f2)->flags) return -1; + if(!((FILEENTRIES *)f1)->flags && ((FILEENTRIES *)f2)->flags) return 1; return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename); } +/*************************************************************************** + * GetCurrentDirectory + * + * Return current browser directory + ***************************************************************************/ +char *GetCurrentDirectory(int selection) +{ + return (deviceType == TYPE_RECENT) ? history.entries[selection].filepath : fileDir; +} + /*************************************************************************** * UpdateDirectory * @@ -176,30 +202,36 @@ int UpdateDirectory(bool go_up, char *dirname) int ParseDirectory(void) { int nbfiles = 0; - char filename[MAXPATHLEN]; - struct stat filestat; /* open directory */ - DIR_ITER *dir = diropen(fileDir); + DIR *dir = opendir(fileDir); if (dir == NULL) { return -1; } - /* list files */ - while ((dirnext(dir, filename, &filestat) == 0) && (nbfiles < MAXFILES)) + struct dirent *entry = readdir(dir); + + /* list entries */ + while ((entry != NULL)&& (nbfiles < MAXFILES)) { - if (filename[0] != '.') + if (entry->d_name[0] != '.') { memset(&filelist[nbfiles], 0, sizeof (FILEENTRIES)); - sprintf(filelist[nbfiles].filename,"%s",filename); - filelist[nbfiles].flags = (filestat.st_mode & S_IFDIR) ? 1 : 0; + sprintf(filelist[nbfiles].filename,"%s",entry->d_name); + if (entry->d_type == DT_DIR) + { + filelist[nbfiles].flags = 1; + } nbfiles++; } + + /* next entry */ + entry = readdir(dir); } /* close directory */ - dirclose(dir); + closedir(dir); /* Sort the file list */ qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback); @@ -214,96 +246,74 @@ int ParseDirectory(void) * This functions return the actual size of data copied into the buffer * ****************************************************************************/ -int LoadFile(u8 *buffer, u32 selection, char *filename) +int LoadFile(int selection) { - char fname[MAXPATHLEN]; - char *filepath; - int done = 0; - struct stat filestat; + char filename[MAXPATHLEN]; /* file path */ - filepath = (deviceType == TYPE_RECENT) ? history.entries[selection].filepath : fileDir; + char *filepath = GetCurrentDirectory(selection); /* full filename */ - sprintf(fname, "%s%s", filepath, filelist[selection].filename); + sprintf(filename, "%s%s", filepath, filelist[selection].filename); - /* retrieve file status */ - if(stat(fname, &filestat) != 0) + /* DVD hot swap */ + if (!strncmp(filepath, rootdir[TYPE_DVD], strlen(rootdir[TYPE_DVD]))) { - /* only DVD hot swap is supported */ - if (!strncmp(filepath, rootdir[TYPE_DVD], strlen(rootdir[TYPE_DVD]))) + /* Check if file is still accessible */ + struct stat filestat; + if(stat(filename, &filestat) != 0) { - /* mount DVD */ + /* If not, try to mount DVD */ if (!MountDVD()) return 0; - - /* retrieve file status */ - stat(fname, &filestat); } } - /* get file length */ - int length = filestat.st_size; + /* try to load ROM file */ + int size = load_rom(filename); - if (length > 0) + if (size > 0) { - /* open file */ - FILE *fd = fopen(fname, "rb"); - if (!fd) + /* add/move the file to the top of the history. */ + history_add_file(filepath, filelist[selection].filename); + + /* recent file list has changed */ + if (deviceType == TYPE_RECENT) deviceType = -1; + + /* auto-save previous game state */ + if (config.s_auto & 2) { - GUI_WaitPrompt("Error","Unable to open file !"); - return 0; + slot_autosave(config.s_default,config.s_device); } - /* Read first data chunk */ - unsigned char temp[FILECHUNK]; - fread(temp, FILECHUNK, 1, fd); - fseek(fd, 0, SEEK_SET); - - /* Determine file type */ - if (!IsZipFile ((char *) temp)) + /* ROM pathname for screenshot, save & cheat files */ + if (!strnicmp(".sms", &filename[strlen(filename) - 4], 4)) { - if (length > MAXROMSIZE) - { - GUI_WaitPrompt("Error","File is too large !"); - return 0; - } - - /* Read file */ - sprintf((char *)temp,"Loading %d bytes ...", length); - GUI_MsgBoxOpen("Information", (char *)temp, 1); - while (length > FILECHUNK) - { - fread(buffer + done, FILECHUNK, 1, fd); - length -= FILECHUNK; - done += FILECHUNK; - } - fread(buffer + done, length, 1, fd); - done += length; - GUI_MsgBoxClose(); - - /* update ROM filename (with extension) */ - sprintf(filename, "%s", filelist[selection].filename); + /* Master System ROM file */ + sprintf(rom_filename,"ms/%s",filelist[selection].filename); + } + else if (!strnicmp(".gg", &filename[strlen(filename) - 3], 3)) + { + /* Game Gear ROM file */ + sprintf(rom_filename,"gg/%s",filelist[selection].filename); + } + else if (!strnicmp(".sg", &filename[strlen(filename) - 3], 3)) + { + /* SG-1000 ROM file */ + sprintf(rom_filename,"sg/%s",filelist[selection].filename); } else { - /* unzip file */ - done = UnZipBuffer(buffer, fd, filename); + /* otherwise, it's Genesis ROM file */ + sprintf(rom_filename,"md/%s",filelist[selection].filename); } - /* close file */ - fclose(fd); + /* remove file extension */ + int i = strlen(rom_filename) - 1; + while ((i > 0) && (rom_filename[i] != '.')) i--; + if (i > 0) rom_filename[i] = 0; - if (done) - { - /* add/move the file to the top of the history. */ - history_add_file(filepath, filelist[selection].filename); - - /* recent file list has changed */ - if (deviceType == TYPE_RECENT) deviceType = -1; - - /* return loaded size */ - return done; - } + /* valid ROM has been loaded */ + return 1; } return 0; @@ -344,7 +354,7 @@ int OpenDirectory(int device) if (device == TYPE_DVD) { /* try to access root directory */ - DIR_ITER *dir = diropen(rootdir[TYPE_DVD]); + DIR *dir = opendir(rootdir[TYPE_DVD]); if (dir == NULL) { /* mount DVD */ @@ -353,7 +363,7 @@ int OpenDirectory(int device) } else { - dirclose(dir); + closedir(dir); } } diff --git a/source/gx/fileio/file_load.h b/source/gx/fileio/file_load.h index 655550d..bb2cc59 100644 --- a/source/gx/fileio/file_load.h +++ b/source/gx/fileio/file_load.h @@ -1,25 +1,41 @@ /* - * file_fat.c + * file_load.c * - * FAT loading support + * ROM File loading support * - * Eke-Eke (2008,2009) + * Copyright Eke-Eke (2008-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ********************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _FILE_FAT_H #define _FILE_FAT_H @@ -34,11 +50,12 @@ #endif #define TYPE_RECENT (TYPE_DVD + 1) -#define FILECHUNK (2048) +#define CHUNKSIZE (2048) extern int OpenDirectory(int device); +extern char *GetCurrentDirectory(int selection); extern int UpdateDirectory(bool go_up, char *filename); extern int ParseDirectory(void); -extern int LoadFile(u8* buffer,u32 selection, char *filename); +extern int LoadFile(int selection); #endif diff --git a/source/gx/fileio/file_slot.c b/source/gx/fileio/file_slot.c index b3c4443..18e1486 100644 --- a/source/gx/fileio/file_slot.c +++ b/source/gx/fileio/file_slot.c @@ -3,24 +3,39 @@ * * FAT and Memory Card SRAM/State slots managment * - * Softdev (2006) - * Eke-Eke (2007,2008,2009) + * Copyright Eke-Eke (2008-2011), based on original code from Softdev (2006) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "file_slot.h" @@ -71,7 +86,7 @@ static int CardMount(int slot) void slot_autoload(int slot, int device) { - if (!cart.romsize) + if (!strlen(rom_filename)) return; SILENT = 1; @@ -81,7 +96,7 @@ void slot_autoload(int slot, int device) void slot_autosave(int slot, int device) { - if (!cart.romsize) + if (!strlen(rom_filename)) return; /* only save if SRAM changed */ @@ -183,7 +198,9 @@ int slot_delete(int slot, int device) sprintf (filename,"%s/saves/%s.gp%d", DEFAULT_PATH, rom_filename, slot - 1); } else + { sprintf (filename,"%s/saves/%s.srm", DEFAULT_PATH, rom_filename); + } /* Delete file */ ret = remove(filename); @@ -268,11 +285,11 @@ int slot_load(int slot, int device) } /* Read into buffer (2k blocks) */ - while (filesize > FILECHUNK) + while (filesize > CHUNKSIZE) { - fread(savebuffer + done, FILECHUNK, 1, fp); - done += FILECHUNK; - filesize -= FILECHUNK; + fread(savebuffer + done, CHUNKSIZE, 1, fp); + done += CHUNKSIZE; + filesize -= CHUNKSIZE; } /* Read remaining bytes */ @@ -436,11 +453,11 @@ int slot_save(int slot, int device) } /* Write from buffer (2k blocks) */ - while (filesize > FILECHUNK) + while (filesize > CHUNKSIZE) { - fwrite(savebuffer + done, FILECHUNK, 1, fp); - done += FILECHUNK; - filesize -= FILECHUNK; + fwrite(savebuffer + done, CHUNKSIZE, 1, fp); + done += CHUNKSIZE; + filesize -= CHUNKSIZE; } /* Write remaining bytes */ diff --git a/source/gx/fileio/file_slot.h b/source/gx/fileio/file_slot.h index 557c21b..20cf225 100644 --- a/source/gx/fileio/file_slot.h +++ b/source/gx/fileio/file_slot.h @@ -3,24 +3,39 @@ * * FAT and Memory Card SRAM/Savestate files managment * - * Softdev (2006) - * Eke-Eke (2007,2008,2009) + * Copyright Eke-Eke (2008-2011), based on original code from Softdev (2006) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _FILE_SLOT_H #define _FILE_SLOT_H diff --git a/source/gx/fileio/fileio.c b/source/gx/fileio/fileio.c new file mode 100644 index 0000000..16f1fc4 --- /dev/null +++ b/source/gx/fileio/fileio.c @@ -0,0 +1,265 @@ +/* + * fileio.c + * + * Load a normal file, or ZIP/GZ archive into ROM buffer. + * Returns loaded ROM size (zero if an error occured). + * + * Copyright Eke-Eke (2007-2011), based on original work from Softdev (2006) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#include "shared.h" +#include "file_load.h" +#include "gui.h" + +/* + * Zip file header definition + */ +typedef struct +{ + unsigned int zipid __attribute__ ((__packed__)); // 0x04034b50 + unsigned short zipversion __attribute__ ((__packed__)); + unsigned short zipflags __attribute__ ((__packed__)); + unsigned short compressionMethod __attribute__ ((__packed__)); + unsigned short lastmodtime __attribute__ ((__packed__)); + unsigned short lastmoddate __attribute__ ((__packed__)); + unsigned int crc32 __attribute__ ((__packed__)); + unsigned int compressedSize __attribute__ ((__packed__)); + unsigned int uncompressedSize __attribute__ ((__packed__)); + unsigned short filenameLength __attribute__ ((__packed__)); + unsigned short extraDataLength __attribute__ ((__packed__)); +} PKZIPHEADER; + + +/* + * Zip files are stored little endian + * Support functions for short and int types + */ +static inline u32 FLIP32 (u32 b) +{ + unsigned int c; + c = (b & 0xff000000) >> 24; + c |= (b & 0xff0000) >> 8; + c |= (b & 0xff00) << 8; + c |= (b & 0xff) << 24; + return c; +} + +static inline u16 FLIP16 (u16 b) +{ + u16 c; + c = (b & 0xff00) >> 8; + c |= (b & 0xff) << 8; + return c; +} + +void get_zipfilename(char *filename) +{ + char in[CHUNKSIZE]; + + /* Open file */ + FILE *fd = fopen(filename, "rb"); + if (!fd) return; + + /* Read first 2 bytes */ + fread(in, 2, 1, fd); + + /* Detect Zip file */ + if (memcmp(in, "PK", 2) == 0) + { + /* Read remaining header data */ + fread(in + 2, sizeof(PKZIPHEADER) - 2, 1, fd); + + /* Zip header pointer */ + PKZIPHEADER *pkzip = (PKZIPHEADER *) in; + + /* Return compressed file name */ + int len = FLIP16(pkzip->filenameLength); + if (len >= MAXPATHLEN) len = MAXPATHLEN - 1; + fread(filename, len, 1, fd); + filename[len] = 0; + } + + fclose(fd); +} + +int load_archive(char *filename) +{ + int size = 0; + char in[CHUNKSIZE]; + char msg[64]; + + /* ROM buffer should be allocated first ! */ + unsigned char *buf = cart.rom; + + /* Open file */ + FILE *fd = fopen(filename, "rb"); + if (!fd) + { + GUI_WaitPrompt("Error","Unable to open file !"); + return 0; + } + + /* clear existing patches before loading new ROM file */ + ggenie_shutdown(); + areplay_shutdown(); + + /* Read first chunk */ + fread(in, CHUNKSIZE, 1, fd); + + /* Detect Zip file */ + if (memcmp(in, "PK", 2) == 0) + { + /* Inflate buffer */ + char out[CHUNKSIZE]; + + /* PKZip header pointer */ + PKZIPHEADER *pkzip = (PKZIPHEADER *) in; + + /* Retrieve uncompressed ROM size */ + size = FLIP32(pkzip->uncompressedSize); + + /* Check ROM size */ + if (size > MAXROMSIZE) + { + fclose(fd); + GUI_WaitPrompt("Error","File is too large !"); + return 0; + } + + sprintf (msg, "Unzipping %d bytes ...", size); + GUI_MsgBoxOpen("Information",msg,1); + + /* Initialize zip stream */ + z_stream zs; + memset (&zs, 0, sizeof (z_stream)); + zs.zalloc = Z_NULL; + zs.zfree = Z_NULL; + zs.opaque = Z_NULL; + zs.avail_in = 0; + zs.next_in = Z_NULL; + int res = inflateInit2(&zs, -MAX_WBITS); + + if (res != Z_OK) + { + fclose(fd); + GUI_WaitPrompt("Error","Unable to unzip file !"); + return 0; + } + + /* Initial Zip buffer offset */ + int offset = sizeof (PKZIPHEADER) + FLIP16(pkzip->filenameLength) + FLIP16(pkzip->extraDataLength); + zs.next_in = (Bytef *)&in[offset]; + + /* Initial Zip remaining chunk size */ + zs.avail_in = CHUNKSIZE - offset; + + /* Get compressed file name */ + offset = FLIP16(pkzip->filenameLength); + if (offset >= MAXPATHLEN) offset = MAXPATHLEN - 1; + strncpy(filename, &in[sizeof(PKZIPHEADER)], offset); + filename[offset] = 0; + + /* Start unzipping file */ + do + { + /* Inflate data until output buffer is empty */ + do + { + zs.avail_out = CHUNKSIZE; + zs.next_out = (Bytef *) out; + res = inflate(&zs, Z_NO_FLUSH); + + if (res == Z_MEM_ERROR) + { + inflateEnd(&zs); + fclose(fd); + GUI_WaitPrompt("Error","Unable to unzip file !"); + return 0; + } + + offset = CHUNKSIZE - zs.avail_out; + if (offset) + { + memcpy(buf, out, offset); + buf += offset; + } + } + while (zs.avail_out == 0); + + /* Read next chunk of zipped data */ + fread(in, CHUNKSIZE, 1, fd); + zs.next_in = (Bytef *)&in[0]; + zs.avail_in = CHUNKSIZE; + } + while (res != Z_STREAM_END); + inflateEnd (&zs); + } + else + { + /* Get file size */ + fseek(fd, 0, SEEK_END); + size = ftell(fd); + fseek(fd, 0, SEEK_SET); + + /* Check file size */ + if(size > MAXROMSIZE) + { + fclose(fd); + GUI_WaitPrompt("Error","File is too large !"); + return 0; + } + + sprintf((char *)msg,"Loading %d bytes ...", size); + GUI_MsgBoxOpen("Information", (char *)msg, 1); + + /* Read into buffer */ + int left = size; + while (left > CHUNKSIZE) + { + fread(buf, CHUNKSIZE, 1, fd); + buf += CHUNKSIZE; + left -= CHUNKSIZE; + } + + /* Read remaining bytes */ + fread(buf, left, 1, fd); + } + + /* Close file */ + fclose(fd); + + /* Return loaded ROM size */ + GUI_MsgBoxClose(); + return size; +} diff --git a/source/gx/fileio/fileio.h b/source/gx/fileio/fileio.h new file mode 100644 index 0000000..b5568f8 --- /dev/null +++ b/source/gx/fileio/fileio.h @@ -0,0 +1,48 @@ +/* + * fileio.c + * + * Load a normal file, or ZIP/GZ archive into ROM buffer. + * Returns loaded ROM size (zero if an error occured). + * + * Copyright Eke-Eke (2007-2011), based on original work from Softdev (2006) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#ifndef _FILEIO_H_ +#define _FILEIO_H_ + +/* Function prototypes */ +void get_zipfilename(char *filename); +int load_archive(char *filename); + +#endif /* _FILEIO_H_ */ diff --git a/source/gx/fileio/history.c b/source/gx/fileio/history.c index f97143a..869f9ff 100644 --- a/source/gx/fileio/history.c +++ b/source/gx/fileio/history.c @@ -3,23 +3,39 @@ * * Generic ROM history list managment * - * Martin Disibio (6/17/08) + * Copyright Eke-Eke (2008-2011), based on original code from Martin Disibio (2008) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ********************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "history.h" diff --git a/source/gx/fileio/history.h b/source/gx/fileio/history.h index 37ac530..d8db744 100644 --- a/source/gx/fileio/history.h +++ b/source/gx/fileio/history.h @@ -3,23 +3,39 @@ * * Generic ROM history list managment * - * Martin Disibio (6/17/08) + * Copyright Eke-Eke (2008-2011), based on original code from Martin Disibio (2008) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ********************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _HISTORY_H #define _HISTORY_H diff --git a/source/gx/gui/cheats.c b/source/gx/gui/cheats.c index c23f3f0..3f50f94 100644 --- a/source/gx/gui/cheats.c +++ b/source/gx/gui/cheats.c @@ -3,24 +3,39 @@ * * Cheats menu * - * Softdev (2006) - * Eke-Eke (2010) + * Copyright Eke-Eke (2010-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ********************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "cheats.h" @@ -34,7 +49,7 @@ #define BG_COLOR_1 {0x49,0x49,0x49,0xff} #define BG_COLOR_2 {0x66,0x66,0x66,0xff} -#define MAX_CHEATS (250) +#define MAX_CHEATS (150) #define MAX_DESC_LENGTH (63) #ifdef HW_RVL @@ -54,23 +69,21 @@ typedef struct u16 data; u16 old; u32 address; + u8 *prev; } CHEATENTRY; -static u32 decode_cheat(char *string, u32 *address, u32 *data); -static void apply_cheats(void); -static void clear_cheats(void); -static void cheatmenu_cb(void); -static void switch_chars(void); - static int string_offset = 0; static int selection = 0; static int offset = 0; static int type = 0; static int maxcheats = 0; +static int maxROMcheats = 0; static int maxRAMcheats = 0; static CHEATENTRY cheatlist[MAX_CHEATS]; -static u8 RAMcheatlist[MAX_CHEATS]; +static u8 cheatIndexes[MAX_CHEATS]; + +static void cheatmenu_cb(void); /*****************************************************************************/ /* GUI Buttons data */ @@ -158,7 +171,7 @@ static gui_item items_cheats[30] = {NULL,NULL,"D","Add Character" ,486,274,40,40}, {NULL,NULL,"E","Add Character" ,532,274,40,40}, {NULL,NULL,"F","Add Character" ,578,274,40,40}, - {NULL,NULL,"del","Delete Entry" ,440,338,40,40}, + {NULL,NULL,"del","Backspace" ,440,338,40,40}, {NULL,NULL,":","Add Separator" ,486,338,40,40}, {NULL,NULL,"+","Next Characters",532,338,40,40}, {NULL,NULL,"ok","Save Entry" ,578,338,40,40} @@ -221,18 +234,24 @@ static char ggvalidchars[] = "ABCDEFGHJKLMNPRSTVWXYZ0123456789"; static char arvalidchars[] = "0123456789ABCDEF"; -static u32 decode_cheat(char *string, u32 *address, u32 *data) +static u32 decode_cheat(char *string, int index) { char *p; int i,n; + u32 len = 0; + u32 address = 0; + u16 data = 0; + u8 ref = 0; - /* reset address & data values */ - *address = 0; - *data = 0; - - /* Game Genie type code (XXXX-YYYY) */ + /* 16-bit Game Genie code (ABCD-EFGH) */ if ((strlen(string) >= 9) && (string[4] == '-')) { + /* 16-bit system only */ + if ((system_hw & SYSTEM_PBC) != SYSTEM_MD) + { + return 0; + } + for (i = 0; i < 8; i++) { if (i == 4) string++; @@ -243,79 +262,191 @@ static u32 decode_cheat(char *string, u32 *address, u32 *data) switch (i) { case 0: - *data |= n << 3; + data |= n << 3; break; case 1: - *data |= n >> 2; - *address |= (n & 3) << 14; + data |= n >> 2; + address |= (n & 3) << 14; break; case 2: - *address |= n << 9; + address |= n << 9; break; case 3: - *address |= (n & 0xF) << 20 | (n >> 4) << 8; + address |= (n & 0xF) << 20 | (n >> 4) << 8; break; case 4: - *data |= (n & 1) << 12; - *address |= (n >> 1) << 16; + data |= (n & 1) << 12; + address |= (n >> 1) << 16; break; case 5: - *data |= (n & 1) << 15 | (n >> 1) << 8; + data |= (n & 1) << 15 | (n >> 1) << 8; break; case 6: - *data |= (n >> 3) << 13; - *address |= (n & 7) << 5; + data |= (n >> 3) << 13; + address |= (n & 7) << 5; break; case 7: - *address |= n; + address |= n; break; } } - /* return code length */ - return 9; + /* code length */ + len = 9; } - /* Action Replay type code (AAAAAA:DDDD) */ - else if ((strlen(string) >= 11) && (string[6] == ':')) + /* 8-bit Game Genie code (DDA-AAA-XXX) */ + else if ((strlen(string) >= 11) && (string[3] == '-') && (string[7] == '-')) { - /* decode address */ - for (i=0; i<6; i++) + /* 8-bit system only */ + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) + { + return 0; + } + + /* decode 8-bit data */ + for (i=0; i<2; i++) { p = strchr (arvalidchars, *string++); if (p == NULL) return 0; - n = (p - arvalidchars) & 15; - *address |= (n << ((5 - i) * 4)); + n = (p - arvalidchars) & 0xF; + data |= (n << ((1 - i) * 4)); } - /* decode data */ - string++; - for (i=0; i<4; i++) + /* decode 16-bit address (low 12-bits) */ + for (i=0; i<3; i++) { + if (i==1) string++; /* skip separator */ p = strchr (arvalidchars, *string++); if (p == NULL) return 0; - n = p - arvalidchars; - *data |= (n & 15) << ((3 - i) * 4); + n = (p - arvalidchars) & 0xF; + address |= (n << ((2 - i) * 4)); } - /* return code length */ - return 11; + /* decode 16-bit address (high 4-bits) */ + p = strchr (arvalidchars, *string++); + if (p == NULL) return 0; + n = (p - arvalidchars) & 0xF; + n ^= 0xF; /* bits inversion */ + address |= (n << 12); + + /* RAM address are also supported */ + if (address >= 0xC000) + { + /* convert to 24-bit Work RAM address */ + address = 0xFF0000 | (address & 0x1FFF); + } + + /* decode reference 8-bit data */ + for (i=0; i<2; i++) + { + string++; /* skip separator and 2nd digit */ + p = strchr (arvalidchars, *string++); + if (p == NULL) return 0; + n = (p - arvalidchars) & 0xF; + ref |= (n << ((1 - i) * 4)); + } + ref = (ref >> 2) | ((ref & 0x03) << 6); /* 2-bit right rotation */ + ref ^= 0xBA; /* XOR */ + + /* update old data value */ + cheatlist[index].old = ref; + + /* code length */ + len = 11; } - return 0; + /* Action Replay code */ + else if (string[6] == ':') + { + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) + { + /* 16-bit code (AAAAAA:DDDD) */ + if (strlen(string) < 11) return 0; + + /* decode 24-bit address */ + for (i=0; i<6; i++) + { + p = strchr (arvalidchars, *string++); + if (p == NULL) return 0; + n = (p - arvalidchars) & 0xF; + address |= (n << ((5 - i) * 4)); + } + + /* decode 16-bit data */ + string++; + for (i=0; i<4; i++) + { + p = strchr (arvalidchars, *string++); + if (p == NULL) return 0; + n = (p - arvalidchars) & 0xF; + data |= (n << ((3 - i) * 4)); + } + + /* code length */ + len = 11; + } + else + { + /* 8-bit code (xxAAAA:DD) */ + if (strlen(string) < 9) return 0; + + /* decode 16-bit address */ + string+=2; + for (i=0; i<4; i++) + { + p = strchr (arvalidchars, *string++); + if (p == NULL) return 0; + n = (p - arvalidchars) & 0xF; + address |= (n << ((3 - i) * 4)); + } + + /* ROM addresses are not supported */ + if (address < 0xC000) return 0; + + /* convert to 24-bit Work RAM address */ + address = 0xFF0000 | (address & 0x1FFF); + + /* decode 8-bit data */ + string++; + for (i=0; i<2; i++) + { + p = strchr (arvalidchars, *string++); + if (p == NULL) return 0; + n = (p - arvalidchars) & 0xF; + data |= (n << ((1 - i) * 4)); + } + + /* code length */ + len = 9; + } + } + + /* Valid code found ? */ + if (len) + { + /* update cheat address & data values */ + cheatlist[index].address = address; + cheatlist[index].data = data; + } + + /* return code length (0 = invalid) */ + return len; } static void apply_cheats(void) { - /* clear RAM patches counter */ - maxRAMcheats = 0; + u8 *ptr; + + /* clear ROM&RAM patches counter */ + maxROMcheats = maxRAMcheats = 0; int i; for (i = 0; i < maxcheats; i++) @@ -324,14 +455,41 @@ static void apply_cheats(void) { if (cheatlist[i].address < cart.romsize) { - /* patch ROM data */ - cheatlist[i].old = *(u16 *)(cart.rom + (cheatlist[i].address & 0xFFFFFE)); - *(u16 *)(cart.rom + (cheatlist[i].address & 0xFFFFFE)) = cheatlist[i].data; + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) + { + /* patch ROM data */ + cheatlist[i].old = *(u16 *)(cart.rom + (cheatlist[i].address & 0xFFFFFE)); + *(u16 *)(cart.rom + (cheatlist[i].address & 0xFFFFFE)) = cheatlist[i].data; + } + else + { + /* add ROM patch */ + maxROMcheats++; + cheatIndexes[MAX_CHEATS - maxROMcheats] = i; + + /* get current banked ROM address */ + ptr = &z80_readmap[(cheatlist[i].address) >> 10][cheatlist[i].address & 0x03FF]; + + /* check if reference matches original ROM data */ + if (((u8)cheatlist[i].old) == *ptr) + { + /* patch data */ + *ptr = cheatlist[i].data; + + /* save patched ROM address */ + cheatlist[i].prev = ptr; + } + else + { + /* no patched ROM address yet */ + cheatlist[i].prev = NULL; + } + } } else if (cheatlist[i].address >= 0xFF0000) { - /* patch RAM data */ - RAMcheatlist[maxRAMcheats++] = i; + /* add RAM patch */ + cheatIndexes[maxRAMcheats++] = i; } } } @@ -344,10 +502,28 @@ static void clear_cheats(void) /* disable cheats in reversed order in case the same address is used by multiple patches */ while (i > 0) { - /* restore original ROM data */ - if (cheatlist[i-1].enable && (cheatlist[i-1].address < cart.romsize)) + if (cheatlist[i-1].enable) { - *(u16 *)(cart.rom + (cheatlist[i-1].address & 0xFFFFFE)) = cheatlist[i-1].old; + if (cheatlist[i-1].address < cart.romsize) + { + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) + { + /* restore original ROM data */ + *(u16 *)(cart.rom + (cheatlist[i-1].address & 0xFFFFFE)) = cheatlist[i-1].old; + } + else + { + /* check if previous banked ROM address has been patched */ + if (cheatlist[i-1].prev != NULL) + { + /* restore original data */ + *cheatlist[i-1].prev = cheatlist[i-1].old; + + /* no more patched ROM address */ + cheatlist[i-1].prev = NULL; + } + } + } } i--; @@ -646,7 +822,6 @@ void CheatMenu(void) int max = 0; char temp[256]; char *str = NULL; - u32 address, data; gui_menu *m = &menu_cheats; /* clear existing ROM patches */ @@ -720,14 +895,6 @@ void CheatMenu(void) /* update menu */ update = GUI_UpdateMenu(m); - /* save offset then restore default */ - if (!(menu_cheats.bg_images[6].state & IMAGE_VISIBLE)) - { - offset = m->offset; - m->offset = 0; - m->max_items = m->max_buttons = 30; - } - /* update selected cheat */ if ((m->selected < 10) && (selection != m->selected)) { @@ -735,6 +902,15 @@ void CheatMenu(void) string_offset = 0; } + /* save offset then restore default */ + if (!(m->bg_images[6].state & IMAGE_VISIBLE)) + { + offset = m->offset; + m->offset = 0; + m->max_items = m->max_buttons = 30; + } + + /* handle pressed buttons */ if (update > 0) { @@ -786,16 +962,32 @@ void CheatMenu(void) else { /* code type */ - if (str[4] == '-') + if (str[6] == ':') { - /* GG code */ + /* Action Replay code */ + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) + { + /* 16-bit code */ + max = 10; + } + else + { + /* 8-bit code */ + max = 8; + } + } + else if (str[4] == '-') + { + /* 16-bit Game Genie code */ max = 8; } else { - /* AR code */ + /* 8-bit Game Genie code */ max = 10; } + + /* set cursor to end of code */ digit_cnt = max + 1; } @@ -843,8 +1035,11 @@ void CheatMenu(void) /* code separator is being deleted */ if ((str[digit_cnt] == ':') || (str[digit_cnt] == '-')) { - /* reset detected code type */ - max = 0; + /* reset detected code type (except 8-bit Game Genie code using 2 separators) */ + if (((system_hw & SYSTEM_PBC) == SYSTEM_MD) || (digit_cnt != 7)) + { + max = 0; + } } /* edit mark */ @@ -874,28 +1069,56 @@ void CheatMenu(void) } else { - /* Separator character (only if code type has not yet been determined) */ - if (max == 0) + /* Separator character */ + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { + /* 16-bit codes */ if (digit_cnt == 4) { - /* GG code */ + /* Game Genie code */ max = 8; str[4] = '-'; - str[5] = '*'; - str[6] = 0; - digit_cnt++; } - else if (digit_cnt == 6) + else if ((digit_cnt == 6) && (max != 8)) { - /* AR code */ + /* Action Replay code */ max = 10; str[6] = ':'; - str[7] = '*'; - str[8] = 0; - digit_cnt++; + } + else + { + break; } } + else + { + /* 8-bit codes */ + if (digit_cnt == 3) + { + /* Game Genie code */ + max = 10; + str[3] = '-'; + } + else if ((digit_cnt == 7) && (max == 10)) + { + /* Game Genie code (last part) */ + str[7] = '-'; + } + else if ((digit_cnt == 6) && (max != 10)) + { + /* Action Replay code */ + max = 8; + str[6] = ':'; + } + else + { + break; + } + } + + digit_cnt++; + str[digit_cnt] = '*'; + str[digit_cnt+1] = 0; } break; } @@ -918,13 +1141,8 @@ void CheatMenu(void) } else if (max && (digit_cnt > max)) { - address = data = 0; - if (decode_cheat(cheatlist[offset + selection].code, &address, &data)) + if (decode_cheat(cheatlist[offset + selection].code, offset + selection)) { - /* update cheat address & data values */ - cheatlist[offset + selection].address = address; - cheatlist[offset + selection].data = data; - /* new cheat ? */ if ((offset + selection) == maxcheats) { @@ -954,6 +1172,9 @@ void CheatMenu(void) /* force code separator if none has been set yet */ if ((max == 0) && (digit_cnt == 6)) break; + /* force 8-bit Game Genie code last separator */ + if (((system_hw & SYSTEM_PBC) != SYSTEM_MD) && (max == 10) && (digit_cnt == 7)) break; + /* add character */ if ((digit_cnt <= max) || (max == 0)) { @@ -1136,7 +1357,6 @@ void CheatLoad(void) { int len; int cnt = 0; - u32 address, data; char temp[256]; /* reset cheat count */ @@ -1160,15 +1380,10 @@ void CheatLoad(void) else temp[strlen(temp) - 1] = 0; /* check cheat validty */ - address = data = 0; - len = decode_cheat(temp, &address, &data); + len = decode_cheat(temp, maxcheats); if (len) { - /* update cheat address & data values */ - cheatlist[maxcheats].address = address; - cheatlist[maxcheats].data = data; - /* copy cheat code */ strncpy(cheatlist[maxcheats].code, temp, len); cheatlist[maxcheats].code[len] = 0; @@ -1231,19 +1446,19 @@ void CheatLoad(void) } /**************************************************************************** - * CheatUpdate + * RAMCheatUpdate * - * Apply RAM patches + * Apply RAM patches (this should be called once per frame) * ****************************************************************************/ -void CheatUpdate(void) +void RAMCheatUpdate(void) { int index, cnt = maxRAMcheats; while (cnt) { /* get cheat index */ - index = RAMcheatlist[--cnt]; + index = cheatIndexes[--cnt]; /* apply RAM patch */ if (cheatlist[index].data & 0xFF00) @@ -1257,4 +1472,49 @@ void CheatUpdate(void) work_ram[cheatlist[index].address & 0xFFFF] = cheatlist[index].data; } } -} \ No newline at end of file +} + + +/**************************************************************************** + * ROMCheatUpdate + * + * Apply ROM patches (this should be called each time banking is changed) + * + ****************************************************************************/ +void ROMCheatUpdate(void) +{ + int index, cnt = maxROMcheats; + u8 *ptr; + + while (cnt) + { + /* get cheat index */ + index = cheatIndexes[MAX_CHEATS - cnt]; + + /* check if previous banked ROM address was patched */ + if (cheatlist[index].prev != NULL) + { + /* restore original data */ + *cheatlist[index].prev = cheatlist[index].old; + + /* no more patched ROM address */ + cheatlist[index].prev = NULL; + } + + /* get current banked ROM address */ + ptr = &z80_readmap[(cheatlist[index].address) >> 10][cheatlist[index].address & 0x03FF]; + + /* check if reference matches original ROM data */ + if (((u8)cheatlist[index].old) == *ptr) + { + /* patch data */ + *ptr = cheatlist[index].data; + + /* save patched ROM address */ + cheatlist[index].prev = ptr; + } + + /* next ROM patch */ + cnt--; + } +} diff --git a/source/gx/gui/cheats.h b/source/gx/gui/cheats.h index 246c6a8..1b61760 100644 --- a/source/gx/gui/cheats.h +++ b/source/gx/gui/cheats.h @@ -3,30 +3,46 @@ * * Cheats menu * - * Softdev (2006) - * Eke-Eke (2010) + * Copyright Eke-Eke (2010-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ********************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _CHEATS_H #define _CHEATS_H extern void CheatMenu(void); extern void CheatLoad(void); -extern void CheatUpdate(void); +extern void RAMCheatUpdate(void); +extern void ROMCheatUpdate(void); #endif diff --git a/source/gx/gui/filesel.c b/source/gx/gui/filesel.c index a39c5e6..a01a1a6 100644 --- a/source/gx/gui/filesel.c +++ b/source/gx/gui/filesel.c @@ -3,30 +3,45 @@ * * ROM File Browser * - * Eke-Eke (2009,2010) + * Copyright Eke-Eke (2009-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ********************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "filesel.h" #include "font.h" #include "gui.h" #include "file_load.h" -#include "file_slot.h" #ifdef HW_RVL #include @@ -35,6 +50,8 @@ #define BG_COLOR_1 {0x49,0x49,0x49,0xff} #define BG_COLOR_2 {0x66,0x66,0x66,0xff} +#define SCROLL_SPEED 10 + extern const u8 Browser_dir_png[]; extern const u8 Snap_empty_png[]; extern const u8 Snap_frame_png[]; @@ -160,15 +177,15 @@ static void selector_cb(void) gxDrawTexture(bar_over.texture,bar_over.x,yoffset+bar_over.y,bar_over.w,bar_over.h,255); /* scrolling text */ - if ((string_offset/10) >= strlen(filelist[i].filename)) + if ((string_offset/SCROLL_SPEED) >= strlen(filelist[i].filename)) { string_offset = 0; } if (string_offset) { - sprintf(text,"%s ",filelist[i].filename+string_offset/10); - strncat(text, filelist[i].filename, string_offset/10); + sprintf(text,"%s ",filelist[i].filename+string_offset/SCROLL_SPEED); + strncat(text, filelist[i].filename, string_offset/SCROLL_SPEED); } else { @@ -182,7 +199,7 @@ static void selector_cb(void) gxDrawTexture(dir_icon.texture,dir_icon.x,yoffset+dir_icon.y,dir_icon.w,dir_icon.h,255); if (FONT_write(text,18,dir_icon.x+dir_icon.w+6,yoffset+22,bar_over.w-dir_icon.w-26,(GXColor)WHITE)) { - /* string is too large -> scroll text */ + /* text scrolling */ string_offset ++; } } @@ -228,11 +245,9 @@ int FileSelector(void) { short p; int i; - int size = 0; int old = -1; char fname[MAXPATHLEN]; - char text[MAXPATHLEN]; - FILE *xml,*snap; + FILE *snap; gui_menu *m = &menu_selector; #ifdef HW_RVL @@ -279,39 +294,74 @@ int FileSelector(void) /* ROM file snapshot/database */ if (old != selection) { + /* close any existing texture first */ + gxTextureClose(&bg_filesel[8].texture); + bg_filesel[8].state &= ~IMAGE_VISIBLE; + old = selection; string_offset = 0; - /* delete previous texture if any */ - gxTextureClose(&bg_filesel[8].texture); - bg_filesel[8].state &= ~IMAGE_VISIBLE; - bg_filesel[6].state &= ~IMAGE_VISIBLE; - if (!filelist[selection].flags) { - /* get ROM filename without extension */ - sprintf (text, "%s", filelist[selection].filename); - int i = strlen(text) - 1; - while ((i > 0) && (text[i] != '.')) i--; - if (i > 0) text[i] = 0; + /* get compressed file name */ + sprintf(fname, "%s/%s", GetCurrentDirectory(selection), filelist[selection].filename); + get_zipfilename(fname); - /* ROM database informations */ - sprintf (fname, "%s/db/%s.xml", DEFAULT_PATH, text); - xml = fopen(fname, "rb"); - if (xml) + /* auto-detect file type */ + if (!strnicmp(".sms", &fname[strlen(fname) - 4], 4)) { - bg_filesel[6].state |= IMAGE_VISIBLE; - fclose(xml); /* TODO */ + /* Master System ROM file */ + sprintf(fname, "%s/snaps/ms/%s", DEFAULT_PATH, filelist[selection].filename); } + else if (!strnicmp(".gg", &fname[strlen(fname) - 3], 3)) + { + /* Game Gear ROM file */ + sprintf(fname, "%s/snaps/gg/%s", DEFAULT_PATH, filelist[selection].filename); + } + else if (!strnicmp(".sg", &fname[strlen(fname) - 3], 3)) + { + /* SG-1000 ROM file */ + sprintf(fname, "%s/snaps/sg/%s", DEFAULT_PATH, filelist[selection].filename); + } + else if ((!strnicmp(".md", &fname[strlen(fname) - 3], 3)) || + (!strnicmp(".gen", &fname[strlen(fname) - 4], 4)) || + (!strnicmp(".bin", &fname[strlen(fname) - 4], 4)) || + (!strnicmp(".mdx", &fname[strlen(fname) - 4], 4)) || + (!strnicmp(".smd", &fname[strlen(fname) - 4], 4))) + { + /* Genesis ROM file */ + sprintf(fname, "%s/snaps/md/%s", DEFAULT_PATH, filelist[selection].filename); + } + else + { + fname[0] = 0; + } + } + else + { + fname[0] = 0; + } - /* open screenshot file */ - sprintf (fname, "%s/snaps/%s.png", DEFAULT_PATH, text); + /* Supported ROM file found ? */ + if (fname[0]) + { + /* remove original file extension */ + i = strlen(fname) - 1; + while ((i > 0) && (fname[i] != '.')) i--; + if (i > 0) fname[i] = 0; + + /* add PNG file extension */ + strcat(fname, ".png"); + + /* try to load screenshot */ snap = fopen(fname, "rb"); if (snap) { bg_filesel[8].texture = gxTextureOpenPNG(0,snap); if (bg_filesel[8].texture) + { bg_filesel[8].state |= IMAGE_VISIBLE; + } fclose(snap); } } @@ -330,7 +380,7 @@ int FileSelector(void) } else { - /* this is a file */ + /* this is a ROM file */ strcpy(action_select.comment,"Load ROM File"); } @@ -477,7 +527,7 @@ int FileSelector(void) /* select previous directory */ for (i=0; iselected < m->max_buttons) + { + if (filelist[selection].flags) + { + /* get new directory */ + UpdateDirectory(0, filelist[selection].filename); + + /* get directory entries */ + maxfiles = ParseDirectory(); + + /* clear selection by default */ + selection = offset = 0; + old = -1; + } + else if (fname[0]) + { + /* load ROM file from device */ + int ret = LoadFile(selection); + + /* exit menu */ + GUI_DeleteMenu(m); + + /* return ROM size (or zero if an error occured) */ + return ret; + } + else + { + /* Unsupported ROM file */ + GUI_WaitPrompt("Error","Unsupported ROM type !"); + } + } + #ifdef HW_RVL /* arrow buttons selected */ - if (m->selected == m->max_buttons) + else if (m->selected == m->max_buttons) { /* up arrow */ selection--; @@ -523,49 +606,6 @@ int FileSelector(void) } #endif - /* ensure we are in focus area */ - if (m->selected < m->max_buttons) - { - if (filelist[selection].flags) - { - /* get new directory */ - UpdateDirectory(0, filelist[selection].filename); - - /* get directory entries */ - maxfiles = ParseDirectory(); - - /* clear selection by default */ - selection = offset = 0; - old = -1; - } - else - { - /* clear existing patches before loading new ROM file */ - ggenie_shutdown(); - areplay_shutdown(); - - /* load ROM file from device */ - size = LoadFile(cart.rom, selection, fname); - - /* exit menu */ - GUI_DeleteMenu(m); - - /* load new game */ - if (size) - { - /* save previous game state */ - if (config.s_auto & 2) - { - slot_autosave(config.s_default,config.s_device); - } - - /* reinitialize emulation */ - reloadrom(size,fname); - } - - return size; - } - } } } } diff --git a/source/gx/gui/filesel.h b/source/gx/gui/filesel.h index 637f526..a2b65f7 100644 --- a/source/gx/gui/filesel.h +++ b/source/gx/gui/filesel.h @@ -3,23 +3,39 @@ * * ROM File Browser * - * Eke-Eke (2009,2010) + * Copyright Eke-Eke (2009-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ********************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _FILESEL_H #define _FILESEL_H @@ -30,7 +46,7 @@ /* Filelist structure */ typedef struct { - char flags; + u8 flags; char filename[MAXJOLIET]; }FILEENTRIES; diff --git a/source/gx/gui/font.c b/source/gx/gui/font.c index 7904b47..52b941f 100644 --- a/source/gx/gui/font.c +++ b/source/gx/gui/font.c @@ -3,23 +3,39 @@ * * IPL font engine (using GX rendering) * - * Eke-Eke (2009,2010) - * - * 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. + * Copyright Eke-Eke (2009-2010) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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 + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - ********************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "font.h" @@ -220,7 +236,7 @@ static void DrawChar(unsigned char c, int xpos, int ypos, int size, GXColor colo GX_Position2s16(xpos, ypos); GX_Color4u8(color.r, color.g, color.b, 0xff); GX_TexCoord2f32(0.0, 1.0); - GX_End (); + GX_End(); GX_DrawDone(); } diff --git a/source/gx/gui/font.h b/source/gx/gui/font.h index 427364b..8b255ee 100644 --- a/source/gx/gui/font.h +++ b/source/gx/gui/font.h @@ -3,23 +3,39 @@ * * IPL font engine (using GX rendering) * - * Eke-Eke (2009,2010) - * - * 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. + * Copyright Eke-Eke (2009-2010) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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 + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - ********************************************************************************/ + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _FONT_H #define _FONT_H diff --git a/source/gx/gui/gui.c b/source/gx/gui/gui.c index 2f9950a..e5a2b2e 100644 --- a/source/gx/gui/gui.c +++ b/source/gx/gui/gui.c @@ -3,23 +3,39 @@ * * generic GUI Engine (using GX rendering) * - * Eke-Eke (2009,2010) + * Copyright Eke-Eke (2009-2010) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "gui.h" diff --git a/source/gx/gui/gui.h b/source/gx/gui/gui.h index dedb29d..c3110f6 100644 --- a/source/gx/gui/gui.h +++ b/source/gx/gui/gui.h @@ -3,23 +3,39 @@ * * generic GUI Engine (using GX rendering) * - * Eke-Eke (2009,2010) + * Copyright Eke-Eke (2009-2010) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _GUI_H #define _GUI_H diff --git a/source/gx/gui/legal.c b/source/gx/gui/legal.c index 1c996a7..d710a01 100644 --- a/source/gx/gui/legal.c +++ b/source/gx/gui/legal.c @@ -3,24 +3,39 @@ * * Genesis Plus GX Disclaimer * - * Softdev (2006) - * Eke-Eke (2007,2008,2009,2010) + * Copyright Eke-Eke (2009-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "font.h" @@ -36,27 +51,26 @@ extern const u8 Bg_intro_c5_png[]; * This is the legal stuff - which must be shown at program startup * Any derivative work MUST include the same textual output. * - * In other words, play nice and give credit where it's due. */ static void show_disclaimer(int ypos) { FONT_writeCenter ("DISCLAIMER",22,0,640,ypos,(GXColor)WHITE); ypos += 32; - FONT_writeCenter ("This is free software, and you are welcome to",20,0,640,ypos,(GXColor)WHITE); + FONT_writeCenter ("This is a free software, and you are welcome",20,0,640,ypos,(GXColor)WHITE); ypos += 20; - FONT_writeCenter ("redistribute it under the conditions of the",20,0,640,ypos,(GXColor)WHITE); + FONT_writeCenter ("to redistribute it under the conditions of the",20,0,640,ypos,(GXColor)WHITE); ypos += 20; - FONT_writeCenter ("GNU GENERAL PUBLIC LICENSE Version 2.",20,0,640,ypos,(GXColor)WHITE); + FONT_writeCenter ("license that you should have received with this",20,0,640,ypos,(GXColor)WHITE); + ypos += 20; + FONT_writeCenter ("program. You may not sell, lease, rent or generally",20,0,640,ypos,(GXColor)WHITE); + ypos += 20; + FONT_writeCenter ("use this software in any commercial product or activity.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("Authors can not be held responsible for any damage or",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("or dysfunction that could occur while using this port.",20,0,640,ypos,(GXColor)WHITE); ypos += 20; - FONT_writeCenter ("You may not sell, lease, rent or generally use",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; - FONT_writeCenter ("this software in any commercial product or activity.",20,0,640,ypos,(GXColor)WHITE); - ypos += 20; FONT_writeCenter ("You may not distribute this software with any ROM image",20,0,640,ypos,(GXColor)WHITE); ypos += 20; FONT_writeCenter ("unless you have the legal right to distribute them.",20,0,640,ypos,(GXColor)WHITE); diff --git a/source/gx/gui/menu.c b/source/gx/gui/menu.c index 0af84fd..081086f 100644 --- a/source/gx/gui/menu.c +++ b/source/gx/gui/menu.c @@ -3,23 +3,39 @@ * * Genesis Plus GX menu * - * Eke-Eke (2009,2010) + * Copyright Eke-Eke (2009-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "menu.h" @@ -31,6 +47,7 @@ #include "file_slot.h" #include +#include #ifdef HW_RVL #include @@ -323,31 +340,32 @@ static gui_item items_options[5] = /* Audio options */ static gui_item items_audio[13] = { - {NULL,NULL,"Master System FM: ON", "Enable/disable YM2413 chip", 56,132,276,48}, - {NULL,NULL,"High-Quality FM: ON", "Enable/disable YM2612/YM2413 resampling", 56,132,276,48}, - {NULL,NULL,"FM Roll-off: 0.999", "Adjust FIR low-pass filtering", 56,132,276,48}, - {NULL,NULL,"FM Resolution: MAX", "Adjust YM2612 DAC precision", 56,132,276,48}, - {NULL,NULL,"FM Volume: 1.00", "Adjust YM2612/YM2413 output level", 56,132,276,48}, - {NULL,NULL,"PSG Volume: 2.50", "Adjust SN76489 output level", 56,132,276,48}, - {NULL,NULL,"PSG Noise Boost: OFF", "Boost SN76489 Noise Channel", 56,132,276,48}, - {NULL,NULL,"Filtering: 3-BAND EQ", "Setup Audio filtering", 56,132,276,48}, - {NULL,NULL,"Low Gain: 1.00", "Adjust EQ Low Band Gain", 56,132,276,48}, - {NULL,NULL,"Mid Gain: 1.00", "Adjust EQ Mid Band Gain", 56,132,276,48}, - {NULL,NULL,"High Gain: 1.00", "Adjust EQ High BandGain", 56,132,276,48}, - {NULL,NULL,"Low Freq: 200 Hz", "Adjust EQ Lowest Frequency", 56,132,276,48}, - {NULL,NULL,"High Freq: 20000 Hz", "Adjust EQ Highest Frequency", 56,132,276,48} + {NULL,NULL,"Master System FM: AUTO", "Enable/disable YM2413 chip", 56,132,276,48}, + {NULL,NULL,"High-Quality FM: ON", "Enable/disable YM2612/YM2413 resampling", 56,132,276,48}, + {NULL,NULL,"FM Roll-off: 0.999", "Adjust FIR low-pass filtering", 56,132,276,48}, + {NULL,NULL,"FM Resolution: MAX", "Adjust YM2612 DAC precision", 56,132,276,48}, + {NULL,NULL,"FM Volume: 1.00", "Adjust YM2612/YM2413 output level", 56,132,276,48}, + {NULL,NULL,"PSG Volume: 2.50", "Adjust SN76489 output level", 56,132,276,48}, + {NULL,NULL,"PSG Noise Boost: OFF", "Boost SN76489 Noise Channel", 56,132,276,48}, + {NULL,NULL,"Filtering: 3-BAND EQ", "Setup Audio filtering", 56,132,276,48}, + {NULL,NULL,"Low Gain: 1.00", "Adjust EQ Low Band Gain", 56,132,276,48}, + {NULL,NULL,"Mid Gain: 1.00", "Adjust EQ Mid Band Gain", 56,132,276,48}, + {NULL,NULL,"High Gain: 1.00", "Adjust EQ High BandGain", 56,132,276,48}, + {NULL,NULL,"Low Freq: 200 Hz", "Adjust EQ Lowest Frequency", 56,132,276,48}, + {NULL,NULL,"High Freq: 20000 Hz", "Adjust EQ Highest Frequency", 56,132,276,48} }; /* System options */ -static gui_item items_system[7] = +static gui_item items_system[8] = { - {NULL,NULL,"Console Region: AUTO", "Select system region", 56,132,276,48}, - {NULL,NULL,"System Lockups: OFF", "Enable/disable original system lock-ups", 56,132,276,48}, - {NULL,NULL,"68k Address Error: ON", "Enable/disable 68k Address Error", 56,132,276,48}, - {NULL,NULL,"System BIOS: OFF", "Enable/disable TMSS BIOS support", 56,132,276,48}, - {NULL,NULL,"Lock-on: OFF", "Select Lock-On cartridge type", 56,132,276,48}, - {NULL,NULL,"Cartridge Swap: OFF", "Enable/disable cartridge hot swap", 56,132,276,48}, - {NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 56,132,276,48} + {NULL,NULL,"Console Hardware: AUTO", "Select system hardware model", 56,132,276,48}, + {NULL,NULL,"Console Region: AUTO", "Select system region", 56,132,276,48}, + {NULL,NULL,"System Lockups: OFF", "Enable/disable original system lock-ups", 56,132,276,48}, + {NULL,NULL,"68k Address Error: ON", "Enable/disable 68k Address Error", 56,132,276,48}, + {NULL,NULL,"System BIOS: OFF", "Enable/disable TMSS BIOS support", 56,132,276,48}, + {NULL,NULL,"Lock-on: OFF", "Select Lock-On cartridge type", 56,132,276,48}, + {NULL,NULL,"Cartridge Swap: OFF", "Enable/disable cartridge hot swap", 56,132,276,48}, + {NULL,NULL,"SVP Cycles: 1500", "Adjust SVP chip emulation speed", 56,132,276,48} }; /* Video options */ @@ -557,7 +575,7 @@ static gui_menu menu_system = { "System Settings", 0,0, - 6,4,6,0, + 7,4,7,0, items_system, buttons_list, bg_list, @@ -828,7 +846,10 @@ static void soundmenu () float hg = (float)config.hg/100.0; int offset = update_snd_items(); - sprintf (items[0].text, "Master System FM: %s", config.ym2413_enabled ? "ON":"OFF"); + + if (config.ym2413 == 0) sprintf (items[0].text, "Master System FM: OFF"); + else if (config.ym2413 == 1) sprintf (items[0].text, "Master System FM: ON"); + else sprintf (items[0].text, "Master System FM: AUTO"); GUI_InitMenu(m); GUI_SlideMenuTitle(m,strlen("Audio ")); @@ -857,43 +878,72 @@ static void soundmenu () switch (ret) { case 0: - config.ym2413_enabled ^= 1; - sprintf (items[0].text, "Master System FM: %s", config.ym2413_enabled ? "ON":"OFF"); + { + config.ym2413++; + if (config.ym2413 > 2) config.ym2413 = 0; + if (config.ym2413 == 0) sprintf (items[0].text, "Master System FM: OFF"); + else if (config.ym2413 == 1) sprintf (items[0].text, "Master System FM: ON"); + else sprintf (items[0].text, "Master System FM: AUTO"); + + /* Automatic detection */ + if ((config.ym2413 & 2) && cart.romsize && ((system_hw & SYSTEM_PBC) != SYSTEM_MD)) + { + /* detect if game is using YM2413 */ + sms_cart_init(); + + /* restore SRAM */ + if (config.s_auto & 1) + { + slot_autoload(0,config.s_device); + } + } break; + } case 1: + { config.hq_fm ^= 1; reinit = 1; offset = update_snd_items(); break; + } case 2: + { config.dac_bits++; if (config.dac_bits > 14) config.dac_bits = 7; - else sprintf (items[offset].text, "FM Resolution: MAX"); if (config.dac_bits < 14) sprintf (items[offset].text, "FM Resolution: %d bits", config.dac_bits); + else sprintf (items[offset].text, "FM Resolution: MAX"); reinit = 1; break; + } case 3: + { GUI_OptionBox(m,0,"FM Volume",(void *)&fm_volume,0.01,0.0,5.0,0); sprintf (items[offset+1].text, "FM Volume: %1.2f", fm_volume); config.fm_preamp = (int)(fm_volume * 100.0 + 0.5); break; + } case 4: + { GUI_OptionBox(m,0,"PSG Volume",(void *)&psg_volume,0.01,0.0,5.0,0); sprintf (items[offset+2].text, "PSG Volume: %1.2f", psg_volume); config.psg_preamp = (int)(psg_volume * 100.0 + 0.5); break; + } case 5: + { config.psgBoostNoise ^= 1; sprintf (items[offset+3].text, "PSG Noise Boost: %s", config.psgBoostNoise ? "ON":"OFF"); SN76489_BoostNoise(config.psgBoostNoise); break; + } case 6: + { config.filter = (config.filter + 1) % 3; if (config.filter == 2) { @@ -922,8 +972,10 @@ static void soundmenu () m->selected++; } break; + } case 7: + { if (config.filter == 1) { GUI_OptionBox(m,0,"Low-Pass Rate",(void *)&config.lp_range,1,0,100,1); @@ -937,42 +989,53 @@ static void soundmenu () audio_set_equalizer(); } break; + } case 8: - GUI_OptionBox(m,0,"Middle Gain",(void *)&mg,0.01,0.0,2.0,0); + { + GUI_OptionBox(m,0,"Middle Gain",(void *)&mg,0.01,0.0,2.0,0); sprintf (items[offset+6].text, "Middle Gain: %1.2f", mg); config.mg = (int)(mg * 100.0); audio_set_equalizer(); break; + } case 9: + { GUI_OptionBox(m,0,"High Gain",(void *)&hg,0.01,0.0,2.0,0); sprintf (items[offset+7].text, "High Gain: %1.2f", hg); config.hg = (int)(hg * 100.0); audio_set_equalizer(); break; + } case 10: + { GUI_OptionBox(m,0,"Low Frequency",(void *)&config.low_freq,10,0,config.high_freq,1); sprintf (items[offset+8].text, "Low Freq: %d", config.low_freq); audio_set_equalizer(); break; + } case 11: + { GUI_OptionBox(m,0,"High Frequency",(void *)&config.high_freq,100,config.low_freq,30000,1); sprintf (items[offset+9].text, "High Freq: %d", config.high_freq); audio_set_equalizer(); break; + } case -1: + { quit = 1; break; + } } } if (reinit && cart.romsize) { - audio_init(snd.sample_rate,snd.frame_rate); + audio_init(snd.sample_rate, snd.frame_rate); sound_restore(); } @@ -998,38 +1061,53 @@ static void systemmenu () gui_menu *m = &menu_system; gui_item *items = m->items; - if (config.region_detect == 0) - sprintf (items[0].text, "Console Region: AUTO"); - else if (config.region_detect == 1) - sprintf (items[0].text, "Console Region: USA"); - else if (config.region_detect == 2) - sprintf (items[0].text, "Console Region: EUR"); - else if (config.region_detect == 3) - sprintf (items[0].text, "Console Region: JAPAN"); + if (config.system == 0) + sprintf (items[0].text, "Console Hardware: AUTO"); + else if (config.system == SYSTEM_SG) + sprintf (items[0].text, "Console Hardware: SG-1000"); + else if (config.system == SYSTEM_MARKIII) + sprintf (items[0].text, "Console Hardware: MARK-III"); + else if (config.system == SYSTEM_SMS) + sprintf (items[0].text, "Console Hardware: SMS"); + else if (config.system == SYSTEM_SMS2) + sprintf (items[0].text, "Console Hardware: SMS-II"); + else if (config.system == SYSTEM_GG) + sprintf (items[0].text, "Console Hardware: GG"); + else if (config.system == SYSTEM_MD) + sprintf (items[0].text, "Console Hardware: MD"); - sprintf (items[1].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); - sprintf (items[2].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); - sprintf (items[3].text, "System TMSS: %s", (config.tmss & 1) ? "ON":"OFF"); + if (config.region_detect == 0) + sprintf (items[1].text, "Console Region: AUTO"); + else if (config.region_detect == 1) + sprintf (items[1].text, "Console Region: USA"); + else if (config.region_detect == 2) + sprintf (items[1].text, "Console Region: EUR"); + else if (config.region_detect == 3) + sprintf (items[1].text, "Console Region: JAPAN"); + + sprintf (items[2].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); + sprintf (items[3].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); + sprintf (items[4].text, "System TMSS: %s", (config.tmss & 1) ? "ON":"OFF"); if (config.lock_on == TYPE_GG) - sprintf (items[4].text, "Lock-On: GAME GENIE"); + sprintf (items[5].text, "Lock-On: GAME GENIE"); else if (config.lock_on == TYPE_AR) - sprintf (items[4].text, "Lock-On: ACTION REPLAY"); + sprintf (items[5].text, "Lock-On: ACTION REPLAY"); else if (config.lock_on == TYPE_SK) - sprintf (items[4].text, "Lock-On: SONIC&KNUCKLES"); + sprintf (items[5].text, "Lock-On: SONIC&KNUCKLES"); else - sprintf (items[4].text, "Lock-On: OFF"); + sprintf (items[5].text, "Lock-On: OFF"); - sprintf (items[5].text, "Cartridge Swap: %s", config.hot_swap ? "ON":"OFF"); + sprintf (items[6].text, "Cartridge Swap: %s", config.hot_swap ? "ON":"OFF"); if (svp) { - sprintf (items[6].text, "SVP Cycles: %d", SVP_cycles); - m->max_items = 7; + sprintf (items[7].text, "SVP Cycles: %d", SVP_cycles); + m->max_items = 8; } else { - m->max_items = 6; + m->max_items = 7; } GUI_InitMenu(m); @@ -1041,21 +1119,118 @@ static void systemmenu () switch (ret) { - case 0: /*** Force Region ***/ + case 0: /*** Force System Hardware ***/ + { + if (config.system == SYSTEM_MD) + { + config.system = 0; + sprintf (items[0].text, "Console Hardware: AUTO"); + + /* Default system hardware (auto) */ + system_hw = romtype; + } + else if (config.system == 0) + { + config.system = SYSTEM_SG; + sprintf (items[0].text, "Console Hardware: SG-1000"); + + /* Force system hardware */ + system_hw = SYSTEM_SG; + } + else if (config.system == SYSTEM_SG) + { + config.system = SYSTEM_MARKIII; + sprintf (items[0].text, "Console Hardware: MARK-III"); + + /* Force system hardware */ + system_hw = SYSTEM_MARKIII; + } + else if (config.system == SYSTEM_MARKIII) + { + config.system = SYSTEM_SMS; + sprintf (items[0].text, "Console Hardware: SMS"); + + /* Force system hardware */ + system_hw = SYSTEM_SMS; + } + else if (config.system == SYSTEM_SMS) + { + config.system = SYSTEM_SMS2; + sprintf (items[0].text, "Console Hardware: SMS-II"); + + /* Force system hardware */ + system_hw = SYSTEM_SMS2; + } + else if (config.system == SYSTEM_SMS2) + { + config.system = SYSTEM_GG; + sprintf (items[0].text, "Console Hardware: GG"); + + if (romtype == SYSTEM_GG) + { + /* Game Gear mode */ + system_hw = SYSTEM_GG; + } + else + { + /* Game Gear in MS compatibility mode */ + system_hw = SYSTEM_GGMS; + } + } + else if (config.system == SYSTEM_GG) + { + config.system = SYSTEM_MD; + sprintf (items[0].text, "Console Hardware: MD"); + + if (romtype & SYSTEM_MD) + { + /* Default mode */ + system_hw = romtype; + } + else + { + /* Mega Drive in MS compatibility mode */ + system_hw = SYSTEM_PBC; + } + } + + /* restart emulation */ + system_init(); + system_reset(); + + /* restore SRAM */ + if (config.s_auto & 1) + { + slot_autoload(0,config.s_device); + } + + break; + } + + case 1: /*** Force Region ***/ + { config.region_detect = (config.region_detect + 1) % 4; if (config.region_detect == 0) - sprintf (items[0].text, "Console Region: AUTO"); + sprintf (items[1].text, "Console Region: AUTO"); else if (config.region_detect == 1) - sprintf (items[0].text, "Console Region: USA"); + sprintf (items[1].text, "Console Region: USA"); else if (config.region_detect == 2) - sprintf (items[0].text, "Console Region: EUR"); + sprintf (items[1].text, "Console Region: EUR"); else if (config.region_detect == 3) - sprintf (items[0].text, "Console Region: JAPAN"); + sprintf (items[1].text, "Console Region: JAPAN"); if (cart.romsize) { /* reset console region */ region_autodetect(); + if (system_hw == SYSTEM_MD) + { + io_reg[0x00] = 0x20 | region_code | (config.tmss & 1); + } + else + { + io_reg[0x00] = 0x80 | (region_code >> 1); + } /* reinitialize audio timings */ if (vdp_pal) @@ -1067,35 +1242,64 @@ static void systemmenu () audio_init(snd.sample_rate, (config.tv_mode == 1) ? 60.0 : ((config.render || interlaced) ? 59.94 : (1000000.0/16715.0))); } - /* reinitialize system emulation */ + /* reintialize VDP */ vdp_init(); - io_init(); - sound_restore(); + + /* reintialize VDP Status flag */ + if (system_hw & SYSTEM_MD) + { + status = (status & ~1) | vdp_pal; + } /* reinitialize VC max value */ - vc_max = vc_table[(reg[1] >> 2) & 3][vdp_pal]; + switch (bitmap.viewport.h) + { + case 192: + vc_max = vc_table[0][vdp_pal]; + break; + case 224: + vc_max = vc_table[1][vdp_pal]; + break; + case 240: + vc_max = vc_table[3][vdp_pal]; + break; + } + + /* reinitialize sound emulation */ + sound_restore(); } break; + } - case 1: /*** force DTACK ***/ + case 2: /*** force DTACK ***/ + { config.force_dtack ^= 1; - sprintf (items[1].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); + sprintf (items[2].text, "System Lockups: %s", config.force_dtack ? "OFF" : "ON"); break; + } - case 2: /*** 68k Address Error ***/ + case 3: /*** 68k Address Error ***/ + { config.addr_error ^= 1; - if (system_hw != SYSTEM_PBC) + if (cart.romsize && ((system_hw & SYSTEM_PBC) == SYSTEM_MD)) { - md_cart_init (); + md_cart_init(); + + /* restore SRAM */ + if (config.s_auto & 1) + { + slot_autoload(0,config.s_device); + } } - sprintf (items[2].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); + sprintf (items[3].text, "68k Address Error: %s", config.addr_error ? "ON" : "OFF"); break; + } - - case 3: /*** BIOS support ***/ + case 4: /*** BIOS support ***/ + { config.tmss ^= 1; - sprintf (items[3].text, "System TMSS: %s", (config.tmss & 1) ? "ON":"OFF"); - if (cart.romsize) + sprintf (items[4].text, "System TMSS: %s", (config.tmss & 1) ? "ON":"OFF"); + if (cart.romsize && ((system_hw & SYSTEM_PBC) == SYSTEM_MD)) { /* restart emulation */ system_init(); @@ -1108,21 +1312,23 @@ static void systemmenu () } } break; + } - case 4: /*** Cart Lock-On ***/ + case 5: /*** Cart Lock-On ***/ + { config.lock_on++; if (config.lock_on > TYPE_SK) config.lock_on = 0; if (config.lock_on == TYPE_GG) - sprintf (items[4].text, "Lock-On: GAME GENIE"); + sprintf (items[5].text, "Lock-On: GAME GENIE"); else if (config.lock_on == TYPE_AR) - sprintf (items[4].text, "Lock-On: ACTION REPLAY"); + sprintf (items[5].text, "Lock-On: ACTION REPLAY"); else if (config.lock_on == TYPE_SK) - sprintf (items[4].text, "Lock-On: SONIC&KNUCKLES"); + sprintf (items[5].text, "Lock-On: SONIC&KNUCKLES"); else - sprintf (items[4].text, "Lock-On: OFF"); + sprintf (items[5].text, "Lock-On: OFF"); - if (cart.romsize) + if (cart.romsize && ((system_hw & SYSTEM_PBC) == SYSTEM_MD)) { /* restart emulation */ system_init(); @@ -1155,20 +1361,27 @@ static void systemmenu () } } break; + } - case 5: /*** Cartridge Hot Swap ***/ + case 6: /*** Cartridge Hot Swap ***/ + { config.hot_swap ^= 1; - sprintf (items[5].text, "Cartridge Swap: %s", config.hot_swap ? "ON":"OFF"); + sprintf (items[6].text, "Cartridge Swap: %s", config.hot_swap ? "ON":"OFF"); break; + } - case 6: /*** SVP cycles per line ***/ + case 7: /*** SVP cycles per line ***/ + { GUI_OptionBox(m,0,"SVP Cycles",(void *)&SVP_cycles,1,1,1500,1); - sprintf (items[6].text, "SVP Cycles: %d", SVP_cycles); + sprintf (items[7].text, "SVP Cycles: %d", SVP_cycles); break; + } case -1: + { quit = 1; break; + } } } @@ -1352,7 +1565,7 @@ static void videomenu () #endif case VI_OFFSET: /*** NTSC filter ***/ - config.ntsc = (config.ntsc + 1) % 4; + config.ntsc = (config.ntsc + 1) & 3; if (config.ntsc == 1) sprintf (items[VI_OFFSET].text, "NTSC Filter: COMPOSITE"); else if (config.ntsc == 2) @@ -1364,7 +1577,7 @@ static void videomenu () break; case VI_OFFSET+1: /*** overscan emulation ***/ - config.overscan = (config.overscan + 1) % 4; + config.overscan = (config.overscan + 1) & 3; if (config.overscan == 3) sprintf (items[VI_OFFSET+1].text, "Borders: ALL"); else if (config.overscan == 2) @@ -1766,6 +1979,21 @@ static void ctrlmenu(void) { case 0: /* update port 1 system */ { + /* fixed configurations */ + if (cart.romsize) + { + if (cart.special & HW_TEREBI_OEKAKI) + { + GUI_WaitPrompt("Error","Terebi Oekaki detected !"); + break; + } + else if (system_hw == SYSTEM_PICO) + { + GUI_WaitPrompt("Error","PICO hardware detected !"); + break; + } + } + /* next connected device */ input.system[0]++; @@ -1784,7 +2012,7 @@ static void ctrlmenu(void) /* allow only one gun type */ if ((input.system[0] == SYSTEM_LIGHTPHASER) && ((input.system[1] == SYSTEM_MENACER) || (input.system[1] == SYSTEM_JUSTIFIER))) { - input.system[0] ++; + input.system[0]++; } /* 4-wayplay uses both ports */ @@ -1844,16 +2072,33 @@ static void ctrlmenu(void) case 1: /* update port 2 system */ { - /* J-CART uses fixed configuration */ - if (cart.special & HW_J_CART) break; + /* fixed configurations */ + if (cart.romsize) + { + if (cart.special & HW_J_CART) + { + GUI_WaitPrompt("Error","J-CART detected !"); + break; + } + else if (cart.special & HW_TEREBI_OEKAKI) + { + GUI_WaitPrompt("Error","Terebi Oekaki detected !"); + break; + } + else if (system_hw == SYSTEM_PICO) + { + GUI_WaitPrompt("Error","PICO hardware detected !"); + break; + } + } /* next connected device */ - input.system[1] ++; + input.system[1]++; /* allow only one connected mouse */ if ((input.system[0] == SYSTEM_MOUSE) && (input.system[1] == SYSTEM_MOUSE)) { - input.system[1] ++; + input.system[1]++; } /* allow only one gun type */ @@ -1871,7 +2116,7 @@ static void ctrlmenu(void) /* XE-1AP on port A only */ if (input.system[1] == SYSTEM_XE_A1P) { - input.system[1] ++; + input.system[1]++; } /* 4-wayplay uses both ports */ @@ -2230,16 +2475,6 @@ static void ctrlmenu(void) config.input[player].port = player%4; } } - - /* force 3-buttons gamepad when using Wiimote */ - if (config.input[player].device == 1) - { - config.input[player].padtype = DEVICE_PAD3B; - if (special) - { - memcpy(&m->items[10],&items[*special],sizeof(gui_item)); - } - } #endif /* update menu items */ @@ -2830,6 +3065,7 @@ static int loadgamemenu () static void showrominfo (void) { char items[15][64]; + char msg[32]; /* fill ROM infos */ sprintf (items[0], "Console Type: %s", rominfo.consoletype); @@ -2881,14 +3117,14 @@ static void showrominfo (void) sprintf (items[11], "ROM end: $%06X", rominfo.romend); if (sram.custom) - sprintf (items[12], "EEPROM(%dK): $%06X", ((eeprom.type.size_mask+1)* 8) /1024, eeprom.type.sda_in_adr); + sprintf (items[12], "EEPROM(%dK): $%06X", ((md_eeprom.type.size_mask+1)* 8) /1024, md_eeprom.type.sda_in_adr); else if (sram.detected) sprintf (items[12], "SRAM Start: $%06X", sram.start); else sprintf (items[12], "No Backup Memory specified"); if (sram.custom) - sprintf (items[13], "EEPROM(%dK): $%06X", ((eeprom.type.size_mask+1)* 8) /1024, eeprom.type.sda_out_adr); + sprintf (items[13], "EEPROM(%dK): $%06X", ((md_eeprom.type.size_mask+1)* 8) /1024, md_eeprom.type.sda_out_adr); else if (sram.detected) sprintf (items[13], "SRAM End: $%06X", sram.end); else if (sram.on) @@ -2905,7 +3141,28 @@ static void showrominfo (void) else if (region_code == REGION_JAPAN_PAL) sprintf (items[14], "Region Code: %s (JPN-PAL)", rominfo.country); - GUI_TextWindow(&menu_main, "ROM Header Info", items, 15, 15); +#ifdef USE_BENCHMARK + /* ROM benchmark */ + if (!config.ntsc) + { + int frames = 0; + u64 start = gettime(); + do + { + system_frame(0); + audio_update(); + } + while (++frames < 300); + u64 end = gettime(); + sprintf(msg,"ROM Header Info (%d fps)", (300 * 1000000) / diff_usec(start,end)); + } + else +#endif + { + strcpy(msg,"ROM Header Info"); + } + + GUI_TextWindow(&menu_main, msg, items, 15, 15); } /*************************************************************************** @@ -2926,10 +3183,10 @@ static void showcredits(void) FONT_writeCenter("Genesis Plus Core", 24, 0, 640, 480 - offset, (GXColor)LIGHT_BLUE); FONT_writeCenter("improved emulation code, fixes & extra features by Eke-Eke", 18, 0, 640, 516 - offset, (GXColor)WHITE); - FONT_writeCenter("original 1.2a version by Charles MacDonald", 18, 0, 640, 534 - offset, (GXColor)WHITE); + FONT_writeCenter("original 1.3 version by Charles MacDonald", 18, 0, 640, 534 - offset, (GXColor)WHITE); FONT_writeCenter("original Z80 core by Juergen Buchmueller", 18, 0, 640, 552 - offset, (GXColor)WHITE); FONT_writeCenter("original 68k Musashi core by Karl Stenerud", 18, 0, 640, 570 - offset, (GXColor)WHITE); - FONT_writeCenter("original YM2612 core by Jarek Burczynski & Tatsuyuki Satoh", 18, 0, 640, 588 - offset, (GXColor)WHITE); + FONT_writeCenter("original YM2612/YM2413 cores by Jarek Burczynski & Tatsuyuki Satoh", 18, 0, 640, 588 - offset, (GXColor)WHITE); FONT_writeCenter("SN76489 core by Maxim", 18, 0, 640, 606 - offset, (GXColor)WHITE); FONT_writeCenter("SVP core by Gravydas Ignotas (Notaz)", 18, 0, 640, 624 - offset, (GXColor)WHITE); FONT_writeCenter("FIR Resampler & NTSC Video Filter by Shay Green (Blargg)", 18, 0, 640, 642 - offset, (GXColor)WHITE); @@ -2960,7 +3217,7 @@ static void showcredits(void) gxSetScreen(); p = m_input.keys; - VIDEO_WaitVSync(); + gxSetScreen(); p |= m_input.keys; offset ++; if (offset > 1144) @@ -3063,7 +3320,7 @@ static void mainmenu_cb(void) } } -void menu_execute(void) +int menu_execute(void) { char filename[MAXPATHLEN]; int status, quit = 0; @@ -3129,7 +3386,7 @@ void menu_execute(void) { /*** Load Game Menu ***/ case 0: - + { GUI_DrawMenuFX(m,30,1); GUI_DeleteMenu(m); @@ -3144,39 +3401,39 @@ void menu_execute(void) break; } - /* exit to game */ + /* exit to game and reinitialize emulation */ gxClearScreen((GXColor)BLACK); gxSetScreen(); - quit = 1; + quit = 2; break; } GUI_InitMenu(m); GUI_DrawMenuFX(m,30,0); break; - + } /*** Options Menu */ case 1: - + { GUI_DrawMenuFX(m,30,1); GUI_DeleteMenu(m); optionmenu(); GUI_InitMenu(m); GUI_DrawMenuFX(m,30,0); break; - + } /*** Exit Menu ***/ case 2: - + { exitmenu(); break; - + } /*** Save Manager ***/ case 3: - + { GUI_DrawMenuFX(m,30,1); GUI_DeleteMenu(m); @@ -3199,11 +3456,11 @@ void menu_execute(void) GUI_InitMenu(m); GUI_DrawMenuFX(m,30,0); break; - + } /*** Virtual system hard reset ***/ case 4: - + { /* check current controller configuration */ if (!gx_input_FindDevices()) { @@ -3228,22 +3485,22 @@ void menu_execute(void) /* exit to game */ quit = 1; break; - + } /*** Cheats menu ***/ case 5: - + { GUI_DrawMenuFX(m,30,1); GUI_DeleteMenu(m); CheatMenu(); GUI_InitMenu(m); GUI_DrawMenuFX(m,30,0); break; - + } /*** Action Replay switch ***/ case 6: - + { status = (areplay_get_status() + 1) % (AR_SWITCH_TRAINER + 1); areplay_set_status(status); status = areplay_get_status(); @@ -3253,12 +3510,12 @@ void menu_execute(void) else m->items[6].data = Button_sm_grey_png; GUI_InitMenu(m); break; - + } /*** Return to Game ***/ case 7: case -1: - + { if (cart.romsize) { /* check current controller configuration */ @@ -3274,21 +3531,25 @@ void menu_execute(void) quit = 1; } break; - + } /*** Game Capture ***/ case 8: - + { + /* PNG filename */ sprintf(filename,"%s/snaps/%s.png", DEFAULT_PATH, rom_filename); + + /* Save file and return */ gxSaveScreenshot(filename); break; - + } /*** ROM information screen ***/ case 9: - + { showrominfo(); break; + } } } @@ -3308,6 +3569,8 @@ void menu_execute(void) MOUSE_Deinit(); } #endif + + return (quit >> 1); } void menu_configure(void) diff --git a/source/gx/gui/menu.h b/source/gx/gui/menu.h index 5c131c8..9efbb4a 100644 --- a/source/gx/gui/menu.h +++ b/source/gx/gui/menu.h @@ -3,28 +3,44 @@ * * Genesis Plus GX menus * - * Eke-Eke (2009) + * Copyright Eke-Eke (2009-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _MENU_H #define _MENU_H -extern void menu_execute(void); +extern int menu_execute(void); extern void menu_configure(void); diff --git a/source/gx/gx_audio.c b/source/gx/gx_audio.c index e098855..472a755 100644 --- a/source/gx/gx_audio.c +++ b/source/gx/gx_audio.c @@ -3,24 +3,39 @@ * * Genesis Plus GX audio support * - * Softdev (2006) - * Eke-Eke (2007,2008,2009) + * Copyright Eke-Eke (2007-2011), based on original work from Softdev (2006) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" @@ -50,7 +65,7 @@ static u32 Bg_music_ogg_size = 0; /* Audio DMA callback */ static void ai_callback(void) { - frameticker++; + frameticker ++; } /* AUDIO engine initialization */ diff --git a/source/gx/gx_audio.h b/source/gx/gx_audio.h index 79fece5..f6288fc 100644 --- a/source/gx/gx_audio.h +++ b/source/gx/gx_audio.h @@ -3,24 +3,39 @@ * * Genesis Plus GX audio support * - * Softdev (2006) - * Eke-Eke (2007,2008,2009) + * Copyright Eke-Eke (2007-2011), based on original work from Softdev (2006) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _GC_AUDIO_H_ #define _GC_AUDIO_H_ diff --git a/source/gx/gx_input.c b/source/gx/gx_input.c index f2de552..ab9350f 100644 --- a/source/gx/gx_input.c +++ b/source/gx/gx_input.c @@ -3,23 +3,39 @@ * * Genesis Plus GX input support * - * Eke-Eke (2008,2009) + * Copyright Eke-Eke (2007-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "font.h" @@ -71,6 +87,7 @@ static u32 wpad_dirmap[3][4] = static char keyname[MAX_KEYS][16]; static int held_cnt = 0; +static int inputs_disabled = 0; /***************************************************************************************/ /* Gamecube PAD support */ @@ -80,60 +97,62 @@ static void pad_config(int chan, int first_key, int last_key) u16 p,key; char msg[64]; - /* reset VSYNC callback */ - VIDEO_SetPostRetraceCallback(NULL); - VIDEO_Flush(); + /* Disable menu inputs update */ + inputs_disabled = 1; /* Check if PAD is connected */ if (!(PAD_ScanPads() & (1< 250) input.analog[0][0] = 250; + if (input.analog[0][1] < 0) input.analog[0][1] = 0; + else if (input.analog[0][1] > 250) input.analog[0][1] = 250; + + /* PEN button */ + if (p & pad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_B; + + break; + } + case DEVICE_ACTIVATOR: { /* Left & right analog stick angle [0-360] */ @@ -475,107 +511,107 @@ static void wpad_config(u8 exp, int chan, int first_key, int last_key) char msg[64]; u32 key,p = 255; - /* remove inputs update callback */ - VIDEO_SetPostRetraceCallback(NULL); - VIDEO_Flush(); + /* Disable menu inputs update */ + inputs_disabled = 1; /* Check if device is connected */ WPAD_Probe(chan, &p); if (((exp > WPAD_EXP_NONE) && (p != exp)) || (p == 255)) { - /* restore inputs update callback */ - VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); - VIDEO_Flush(); - if (exp == WPAD_EXP_NONE) sprintf(msg, "WIIMOTE #%d is not connected !", chan+1); if (exp == WPAD_EXP_NUNCHUK) sprintf(msg, "NUNCHUK #%d is not connected !", chan+1); if (exp == WPAD_EXP_CLASSIC) sprintf(msg, "CLASSIC #%d is not connected !", chan+1); GUI_WaitPrompt("Error",msg); + inputs_disabled = 0; return; } /* loop on each mapped keys */ do { - /* remove any pending buttons */ - while (WPAD_ButtonsHeld(chan)) + /* check for unused keys */ + if (strcmp(keyname[first_key], "N.A")) { - WPAD_ScanPads(); - VIDEO_WaitVSync(); - } - - /* wait for user input */ - sprintf(msg,"Press key for %s\n(HOME to return)",keyname[first_key]); - GUI_MsgBoxUpdate(0,msg); - - /* wait for input */ - key = 0; - while (!key) - { - VIDEO_WaitVSync(); - WPAD_ScanPads(); - p = WPAD_ButtonsDown(chan); - - switch (exp) + /* remove any pending buttons */ + while (WPAD_ButtonsHeld(chan)) { - /* Wiimote (TODO: add motion sensing !) */ - case WPAD_EXP_NONE: - { - if (p & WPAD_BUTTON_HOME) key = 0xff; - else if (p & WPAD_BUTTON_2) key = WPAD_BUTTON_2; - else if (p & WPAD_BUTTON_1) key = WPAD_BUTTON_1; - else if (p & WPAD_BUTTON_B) key = WPAD_BUTTON_B; - else if (p & WPAD_BUTTON_A) key = WPAD_BUTTON_A; - else if (p & WPAD_BUTTON_PLUS) key = WPAD_BUTTON_PLUS; - else if (p & WPAD_BUTTON_MINUS) key = WPAD_BUTTON_MINUS; - break; - } + WPAD_ScanPads(); + VIDEO_WaitVSync(); + } - /* Wiimote + Nunchuk (TODO: add motion sensing !) */ - case WPAD_EXP_NUNCHUK: - { - if (p & WPAD_BUTTON_HOME) key = 0xff; - else if (p & WPAD_BUTTON_2) key = WPAD_BUTTON_2; - else if (p & WPAD_BUTTON_1) key = WPAD_BUTTON_1; - else if (p & WPAD_BUTTON_B) key = WPAD_BUTTON_B; - else if (p & WPAD_BUTTON_A) key = WPAD_BUTTON_A; - else if (p & WPAD_BUTTON_PLUS) key = WPAD_BUTTON_PLUS; - else if (p & WPAD_BUTTON_MINUS) key = WPAD_BUTTON_MINUS; - else if (p & WPAD_NUNCHUK_BUTTON_Z) key = WPAD_NUNCHUK_BUTTON_Z; - else if (p & WPAD_NUNCHUK_BUTTON_C) key = WPAD_NUNCHUK_BUTTON_C; - break; - } + /* wait for user input */ + sprintf(msg,"Press key for %s\n(HOME to return)",keyname[first_key]); + GUI_MsgBoxUpdate(0,msg); - /* Classic Controller */ - case WPAD_EXP_CLASSIC: - { - if (p & WPAD_CLASSIC_BUTTON_HOME) key = 0xff; - else if (p & WPAD_CLASSIC_BUTTON_X) key = WPAD_CLASSIC_BUTTON_X; - else if (p & WPAD_CLASSIC_BUTTON_A) key = WPAD_CLASSIC_BUTTON_A; - else if (p & WPAD_CLASSIC_BUTTON_Y) key = WPAD_CLASSIC_BUTTON_Y; - else if (p & WPAD_CLASSIC_BUTTON_B) key = WPAD_CLASSIC_BUTTON_B; - else if (p & WPAD_CLASSIC_BUTTON_ZL) key = WPAD_CLASSIC_BUTTON_ZL; - else if (p & WPAD_CLASSIC_BUTTON_ZR) key = WPAD_CLASSIC_BUTTON_ZR; - else if (p & WPAD_CLASSIC_BUTTON_PLUS) key = WPAD_CLASSIC_BUTTON_PLUS; - else if (p & WPAD_CLASSIC_BUTTON_MINUS) key = WPAD_CLASSIC_BUTTON_MINUS; - else if (p & WPAD_CLASSIC_BUTTON_FULL_L) key = WPAD_CLASSIC_BUTTON_FULL_L; - else if (p & WPAD_CLASSIC_BUTTON_FULL_R) key = WPAD_CLASSIC_BUTTON_FULL_R; - break; - } + /* wait for input */ + key = 0; + while (!key) + { + VIDEO_WaitVSync(); + WPAD_ScanPads(); + p = WPAD_ButtonsDown(chan); - default: + switch (exp) { - key = 0xff; - break; + /* Wiimote (TODO: add motion sensing !) */ + case WPAD_EXP_NONE: + { + if (p & WPAD_BUTTON_HOME) key = 0xff; + else if (p & WPAD_BUTTON_2) key = WPAD_BUTTON_2; + else if (p & WPAD_BUTTON_1) key = WPAD_BUTTON_1; + else if (p & WPAD_BUTTON_B) key = WPAD_BUTTON_B; + else if (p & WPAD_BUTTON_A) key = WPAD_BUTTON_A; + else if (p & WPAD_BUTTON_PLUS) key = WPAD_BUTTON_PLUS; + else if (p & WPAD_BUTTON_MINUS) key = WPAD_BUTTON_MINUS; + break; + } + + /* Wiimote + Nunchuk (TODO: add motion sensing !) */ + case WPAD_EXP_NUNCHUK: + { + if (p & WPAD_BUTTON_HOME) key = 0xff; + else if (p & WPAD_BUTTON_2) key = WPAD_BUTTON_2; + else if (p & WPAD_BUTTON_1) key = WPAD_BUTTON_1; + else if (p & WPAD_BUTTON_B) key = WPAD_BUTTON_B; + else if (p & WPAD_BUTTON_A) key = WPAD_BUTTON_A; + else if (p & WPAD_BUTTON_PLUS) key = WPAD_BUTTON_PLUS; + else if (p & WPAD_BUTTON_MINUS) key = WPAD_BUTTON_MINUS; + else if (p & WPAD_NUNCHUK_BUTTON_Z) key = WPAD_NUNCHUK_BUTTON_Z; + else if (p & WPAD_NUNCHUK_BUTTON_C) key = WPAD_NUNCHUK_BUTTON_C; + break; + } + + /* Classic Controller */ + case WPAD_EXP_CLASSIC: + { + if (p & WPAD_CLASSIC_BUTTON_HOME) key = 0xff; + else if (p & WPAD_CLASSIC_BUTTON_X) key = WPAD_CLASSIC_BUTTON_X; + else if (p & WPAD_CLASSIC_BUTTON_A) key = WPAD_CLASSIC_BUTTON_A; + else if (p & WPAD_CLASSIC_BUTTON_Y) key = WPAD_CLASSIC_BUTTON_Y; + else if (p & WPAD_CLASSIC_BUTTON_B) key = WPAD_CLASSIC_BUTTON_B; + else if (p & WPAD_CLASSIC_BUTTON_ZL) key = WPAD_CLASSIC_BUTTON_ZL; + else if (p & WPAD_CLASSIC_BUTTON_ZR) key = WPAD_CLASSIC_BUTTON_ZR; + else if (p & WPAD_CLASSIC_BUTTON_PLUS) key = WPAD_CLASSIC_BUTTON_PLUS; + else if (p & WPAD_CLASSIC_BUTTON_MINUS) key = WPAD_CLASSIC_BUTTON_MINUS; + else if (p & WPAD_CLASSIC_BUTTON_FULL_L) key = WPAD_CLASSIC_BUTTON_FULL_L; + else if (p & WPAD_CLASSIC_BUTTON_FULL_R) key = WPAD_CLASSIC_BUTTON_FULL_R; + break; + } + + default: + { + key = 0xff; + break; + } } } - } - /* exit */ - if (key == 0xff) break; - - /* update key mapping */ - config.wpad_keymap[exp + (chan * 3)][first_key] = key; + /* exit */ + if (key == 0xff) break; + + /* update key mapping */ + config.wpad_keymap[exp + (chan * 3)][first_key] = key; + } } while (first_key++ < last_key); @@ -586,9 +622,8 @@ static void wpad_config(u8 exp, int chan, int first_key, int last_key) VIDEO_WaitVSync(); } - /* restore inputs update callback */ - VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); - VIDEO_Flush(); + /* Enable menu inputs update */ + inputs_disabled = 0; } static void wpad_update(s8 chan, u8 i, u32 exp) @@ -860,7 +895,7 @@ static void wpad_update(s8 chan, u8 i, u32 exp) break; } - case DEVICE_TABLET: + case DEVICE_PICO: { /* D-PAD */ if (p & PAD_BUTTON_UP) input.pad[i] |= INPUT_UP; @@ -897,6 +932,36 @@ static void wpad_update(s8 chan, u8 i, u32 exp) break; } + case DEVICE_TEREBI: + { + /* PEN screen position (x,y) */ + input.analog[0][0] += x / ANALOG_SENSITIVITY; + input.analog[0][1] -= y / ANALOG_SENSITIVITY; + + /* Limits */ + if (input.analog[0][0] < 0) input.analog[0][0] = 0; + else if (input.analog[0][0] > 250) input.analog[0][0] = 250; + if (input.analog[0][1] < 0) input.analog[0][1] = 0; + else if (input.analog[0][1] > 250) input.analog[0][1] = 250; + + /* Wiimote IR */ + if (exp != WPAD_EXP_CLASSIC) + { + struct ir_t ir; + WPAD_IR(chan, &ir); + if (ir.valid) + { + input.analog[0][0] = (ir.x * 250) / 640; + input.analog[0][1] = (ir.y * 250) / 480; + } + } + + /* PEN button */ + if (p & wpad_keymap[KEY_BUTTONA]) input.pad[i] |= INPUT_B; + + break; + } + case DEVICE_ACTIVATOR: { /* Classic Controller only */ @@ -949,17 +1014,13 @@ static void wpad_update(s8 chan, u8 i, u32 exp) /***************************************************************************************/ void gx_input_Init(void) { - PAD_Init (); - + PAD_Init(); #ifdef HW_RVL WPAD_Init(); WPAD_SetIdleTimeout(60); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL,640,480); #endif - - VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); - VIDEO_Flush(); } int gx_input_FindDevices(void) @@ -1233,27 +1294,33 @@ void gx_input_Config(u8 chan, u8 device, u8 type) case DEVICE_LIGHTGUN: { - if ((input.system[1] == SYSTEM_MENACER) || (input.system[1] == SYSTEM_JUSTIFIER)) + first_key = KEY_BUTTONA; + last_key = KEY_START; + if (input.system[1] == SYSTEM_MENACER) { - first_key = KEY_BUTTONA; - last_key = KEY_START; - sprintf(keyname[KEY_BUTTONA],"Button A"); + sprintf(keyname[KEY_BUTTONA],"TRIGGER Button"); sprintf(keyname[KEY_BUTTONB],"Button B"); sprintf(keyname[KEY_BUTTONC],"Button C"); sprintf(keyname[KEY_START],"START Button"); } + else if (input.system[1] == SYSTEM_JUSTIFIER) + { + sprintf(keyname[KEY_BUTTONA],"TRIGGER Button"); + sprintf(keyname[KEY_BUTTONB],"N.A"); + sprintf(keyname[KEY_BUTTONC],"N.A"); + sprintf(keyname[KEY_START],"START Button"); + } else { - first_key = KEY_BUTTONB; - last_key = KEY_START; - sprintf(keyname[KEY_BUTTONB],"Button 1 (Fire)"); - sprintf(keyname[KEY_BUTTONC],"Button 2"); + sprintf(keyname[KEY_BUTTONA],"TRIGGER Button"); + sprintf(keyname[KEY_BUTTONB],"N.A"); + sprintf(keyname[KEY_BUTTONC],"N.A"); sprintf(keyname[KEY_START],"PAUSE Button"); } break; } - case DEVICE_TABLET: + case DEVICE_PICO: { first_key = KEY_BUTTONA; last_key = KEY_BUTTONB; @@ -1262,6 +1329,14 @@ void gx_input_Config(u8 chan, u8 device, u8 type) break; } + case DEVICE_TEREBI: + { + first_key = KEY_BUTTONA; + last_key = KEY_BUTTONA; + sprintf(keyname[KEY_BUTTONA],"PEN Button"); + break; + } + default: { GUI_WaitPrompt("Info","Activator is not configurable !"); @@ -1322,12 +1397,15 @@ void gx_input_UpdateEmu(void) } /* Update RAM patches */ - CheatUpdate(); + RAMCheatUpdate(); } /* Menu inputs update function (done by Video Interrupt callback) */ -void gx_input_UpdateMenu(u32 cnt) +void gx_input_UpdateMenu(void) { + /* Check if inputs update are disabled */ + if (inputs_disabled) return; + /* PAD status update */ PAD_ScanPads(); diff --git a/source/gx/gx_input.h b/source/gx/gx_input.h index 1b9f85b..d4d228f 100644 --- a/source/gx/gx_input.h +++ b/source/gx/gx_input.h @@ -3,23 +3,39 @@ * * Genesis Plus GX input support * - * Eke-Eke (2008,2009) + * Copyright Eke-Eke (2007-2011) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _GC_INPUT_H_ #define _GC_INPUT_H_ @@ -48,6 +64,6 @@ extern int gx_input_FindDevices(void); extern void gx_input_SetDefault(void); extern void gx_input_Config(u8 chan, u8 device, u8 type); extern void gx_input_UpdateEmu(void); -extern void gx_input_UpdateMenu(u32 cnt); +extern void gx_input_UpdateMenu(void); #endif diff --git a/source/gx/gx_video.c b/source/gx/gx_video.c index 8e52d12..1ab503c 100644 --- a/source/gx/gx_video.c +++ b/source/gx/gx_video.c @@ -3,30 +3,45 @@ * * Genesis Plus GX video & rendering support * - * Softdev (2006) - * Eke-Eke (2007,2008,2009) + * Copyright Eke-Eke (2007-2011), based on original work from Softdev (2006) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #include "shared.h" #include "font.h" -#include "aram.h" #include "md_ntsc.h" #include "sms_ntsc.h" +#include "gx_input.h" #include @@ -53,7 +68,7 @@ u8 *texturemem; /* Texture Data */ u8 *screenshot; /* Texture Data */ /*** 50/60hz flag ***/ -u32 gc_pal = 0; +u32 gc_pal; /*** NTSC Filters ***/ sms_ntsc_t *sms_ntsc; @@ -336,7 +351,7 @@ static camera cam = { /* VSYNC callback */ static void vi_callback(u32 cnt) { - frameticker++; + frameticker ++; } /* Vertex Rendering */ @@ -354,7 +369,7 @@ static inline void draw_square(void) draw_vert(2, 1.0, 0.0); draw_vert(1, 1.0, 1.0); draw_vert(0, 0.0, 1.0); - GX_End (); + GX_End(); } /* Initialize GX */ @@ -466,7 +481,7 @@ static void gxSetAspectRatio(int *xscale, int *yscale) else { /* overscan is simulated (black) */ - *yscale = bitmap.viewport.h / 2; + *yscale = vheight / 2; if (vdp_pal && (!gc_pal || config.render)) *yscale = *yscale * 240 / 288; else if (!vdp_pal && gc_pal && !config.render) @@ -476,23 +491,23 @@ static void gxSetAspectRatio(int *xscale, int *yscale) /* horizontal borders */ if (config.overscan & 2) { - /* max visible range is ~712 pixels, not 720 */ - *xscale = (reg[12] & 1) ? 356 : 360; + /* max visible range is ~712 pixels (= 348 'H40' pixels) */ + *xscale = (reg[12] & 1) ? 356 : 363; } else { /* overscan is simulated (black) */ - *xscale = 327; + *xscale = (system_hw == SYSTEM_GG) ? 204 : 327; } - /* 16/9 correction */ + /* aspect correction for 16:9 screens */ if (config.aspect & 2) { *xscale = (*xscale * 3) / 4; } } - /* manual aspect ratio (default is unscaled raw) */ + /* manual aspect ratio (default is full screen & not scaled if possible) */ else { /* vertical borders */ @@ -508,7 +523,7 @@ static void gxSetAspectRatio(int *xscale, int *yscale) /* horizontal borders */ if (config.overscan & 2) { - *xscale = 348; + *xscale = (reg[12] & 1) ? 348 : 355; } else { @@ -620,8 +635,8 @@ static void gxDrawCrosshair(gx_texture *texture, int x, int y) int h = (texture->height * rmode->efbHeight) / (rmode->viHeight); /* adjust texture coordinates to EFB */ - int fb_w = square[3] - square[9]; - int fb_h = square[4] - square[10]; + int fb_w = square[3] - square[9]; + int fb_h = square[4] - square[10]; x = (((x + bitmap.viewport.x) * fb_w) / (bitmap.viewport.w + 2*bitmap.viewport.x)) - w/2 - (fb_w/2); y = (((y + bitmap.viewport.y) * fb_h) / (bitmap.viewport.h + 2*bitmap.viewport.y)) - h/2 - (fb_h/2); @@ -639,7 +654,7 @@ static void gxDrawCrosshair(gx_texture *texture, int x, int y) GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(0.0, 0.0); - GX_End (); + GX_End(); /* restore GX rendering */ gxResetRendering(0); @@ -675,7 +690,7 @@ void gxDrawRectangle(s32 x, s32 y, s32 w, s32 h, u8 alpha, GXColor color) GX_Color4u8(color.r,color.g,color.b,alpha); GX_Position2s16(x,y); GX_Color4u8(color.r,color.g,color.b,alpha); - GX_End (); + GX_End(); GX_DrawDone(); /* restore GX rendering */ @@ -714,7 +729,7 @@ void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha) GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 0.0); - GX_End (); + GX_End(); GX_DrawDone(); } } @@ -759,7 +774,7 @@ void gxDrawTextureRotate(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, f32 an GX_Position2s16(-w/2,h/2); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 1.0); - GX_End (); + GX_End(); GX_DrawDone(); /* restore default Modelview */ @@ -802,7 +817,7 @@ void gxDrawTextureRepeat(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alp GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 0.0); - GX_End (); + GX_End(); GX_DrawDone(); } } @@ -834,6 +849,12 @@ void gxDrawScreenshot(u8 alpha) s32 w = xscale * 2; s32 h = yscale * 4; + /* black out surrounding area if necessary (Game Gear without borders) */ + if ((w < 640) || (h < 480)) + { + gxDrawRectangle(0, 0, 640, 480, 255, (GXColor)BLACK); + } + /* draw textured quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(x,y+h); @@ -848,7 +869,7 @@ void gxDrawScreenshot(u8 alpha) GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,alpha); GX_TexCoord2f32(0.0, 0.0); - GX_End (); + GX_End(); GX_DrawDone(); } @@ -861,11 +882,17 @@ void gxCopyScreenshot(gx_texture *texture) GX_InvalidateTexAll(); /* scale texture to EFB width */ - s32 w = bitmap.viewport.x ? 696 : 640; + s32 w = ((bitmap.viewport.w + 2*bitmap.viewport.x) * 640) / bitmap.viewport.w; s32 h = (bitmap.viewport.h + 2*bitmap.viewport.y) * 2; s32 x = -w/2; s32 y = -(240+ 2*bitmap.viewport.y); + /* black out surrounding area if necessary (Game Gear without borders) */ + if ((w < 640) || (h < 480)) + { + gxDrawRectangle(0, 0, 640, 480, 255, (GXColor)BLACK); + } + /* draw textured quad */ GX_Begin(GX_QUADS, GX_VTXFMT0, 4); GX_Position2s16(x,y+h); @@ -880,7 +907,7 @@ void gxCopyScreenshot(gx_texture *texture) GX_Position2s16(x,y); GX_Color4u8(0xff,0xff,0xff,0xff); GX_TexCoord2f32(0.0, 0.0); - GX_End (); + GX_End(); /* copy EFB to texture */ texture->format = GX_TF_RGBA8; @@ -928,6 +955,7 @@ void gxSetScreen(void) VIDEO_SetNextFramebuffer (xfb[whichfb]); VIDEO_Flush (); VIDEO_WaitVSync (); + gx_input_UpdateMenu(); } void gxClearScreen(GXColor color) @@ -1315,7 +1343,6 @@ void gx_video_Stop(void) /* default VI settings */ VIDEO_SetPreRetraceCallback(NULL); - VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu); #ifdef HW_RVL VIDEO_SetTrapFilter(1); VIDEO_SetGamma(VI_GM_1_0); @@ -1355,9 +1382,8 @@ void gx_video_Start(void) if (gc_pal == vdp_pal) { VIDEO_SetPreRetraceCallback(vi_callback); + VIDEO_Flush(); } - VIDEO_SetPostRetraceCallback(NULL); - VIDEO_Flush(); /* set interlaced or progressive video mode */ if (config.render == 2) @@ -1371,8 +1397,17 @@ void gx_video_Start(void) tvmodes[2]->xfbMode = VI_XFBMODE_DF; } + /* update horizontal border width */ + if (system_hw == SYSTEM_GG) + { + bitmap.viewport.x = (config.overscan & 2) ? 14 : -48; + } + else + { + bitmap.viewport.x = (config.overscan & 2) * 7; + } + /* force viewport update */ - bitmap.viewport.x = (config.overscan & 2) * 7; bitmap.viewport.changed = 3; /* NTSC filter */ @@ -1407,19 +1442,46 @@ void gx_video_Start(void) } /* lightgun textures */ - if (config.gun_cursor[0] && ((input.system[1] == SYSTEM_MENACER) || (input.system[1] == SYSTEM_JUSTIFIER) || (input.system[0] == SYSTEM_LIGHTPHASER))) + int i, player = 0; + for (i=0; i= 0) + { + if ((i == 0) || ((i == 4) && (input.system[1] != SYSTEM_LIGHTPHASER))) + { + /* Lightgun #1 */ + if (config.gun_cursor[0]) + { + crosshair[0] = gxTextureOpenPNG(Crosshair_p1_png,0); + } + } + else + { + /* Lightgun #2 */ + if (config.gun_cursor[1]) + { + crosshair[1] = gxTextureOpenPNG(Crosshair_p2_png,0); + } + } + } + } + + /* Check for any emulated device */ + if (input.dev[i] != NO_DEVICE) + { + /* increment player index */ + player++; + } } /* GX emulation rendering */ gxResetRendering(0); - /* resynchronize emulation with VSYNC*/ + /* resynchronize emulation with VSYNC */ VIDEO_WaitVSync(); } @@ -1493,7 +1555,7 @@ void gx_video_Update(void) /* render textured quad */ draw_square(); - /* Lightgun # 1 screen mark */ + /* lightgun # 1 screen mark */ if (crosshair[0]) { if (input.system[0] == SYSTEM_LIGHTPHASER) @@ -1506,12 +1568,12 @@ void gx_video_Update(void) } } - /* Lightgun # 2 screen mark */ + /* lightgun #2 screen mark */ if (crosshair[1]) { if (input.system[1] == SYSTEM_LIGHTPHASER) { - gxDrawCrosshair(crosshair[1], input.analog[1][0],input.analog[1][1]); + gxDrawCrosshair(crosshair[1], input.analog[4][0],input.analog[4][1]); } else { @@ -1533,7 +1595,7 @@ void gx_video_Update(void) if (update) { - /* Clear update flags */ + /* clear update flags */ bitmap.viewport.changed &= ~1; /* field synchronization */ @@ -1561,19 +1623,6 @@ void gx_video_Init(void) */ VIDEO_Init(); - /* - * Before any memory is allocated etc. - * Rescue any tagged ROM in data 2 - */ - int *romptr = (int *)0x80700000; - StartARAM(); - cart.romsize = 0; - if (memcmp((char *)romptr,"GENPLUSR",8) == 0) - { - cart.romsize = romptr[2]; - ARAMPut((char *) 0x80700000 + 0x20, (char *) 0x8000, cart.romsize); - } - /* Get the current VIDEO mode then : - set menu VIDEO mode (480p, 480i or 576i) - set emulator rendering TV modes (PAL/MPAL/NTSC/EURGB60) @@ -1647,32 +1696,11 @@ void gx_video_Init(void) gxResetMode(vmode); /* initialize FONT */ - if (!FONT_Init()) - { -#ifdef HW_RVL - DI_Close(); - SYS_ResetSystem(SYS_RESTART,0,0); -#else - SYS_ResetSystem(SYS_HOTRESET,0,0); -#endif - } + FONT_Init(); /* Initialize textures */ texturemem = memalign(32, TEX_SIZE); screenshot = memalign(32, HASPECT*VASPECT*4); - if (!texturemem || !screenshot) - { - FONT_writeCenter("Failed to allocate textures memory... Rebooting",18,0,640,200,(GXColor)WHITE); - gxSetScreen(); - sleep(2); - gx_video_Shutdown(); -#ifdef HW_RVL - DI_Close(); - SYS_ResetSystem(SYS_RESTART,0,0); -#else - SYS_ResetSystem(SYS_HOTRESET,0,0); -#endif - } } void gx_video_Shutdown(void) diff --git a/source/gx/gx_video.h b/source/gx/gx_video.h index 9490e1c..918d406 100644 --- a/source/gx/gx_video.h +++ b/source/gx/gx_video.h @@ -3,24 +3,39 @@ * * Genesis Plus GX video support * - * Softdev (2006) - * Eke-Eke (2007,2008,2009) + * Copyright Eke-Eke (2007-2011), based on original work from Softdev (2006) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - ***************************************************************************/ + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ #ifndef _GC_VIDEO_H_ #define _GC_VIDEO_H_ @@ -47,7 +62,6 @@ extern GXRModeObj *vmode; extern u8 *texturemem; extern u32 gc_pal; - /* GX rendering */ extern void gxDrawRectangle(s32 x, s32 y, s32 w, s32 h, u8 alpha, GXColor color); extern void gxDrawTexture(gx_texture *texture, s32 x, s32 y, s32 w, s32 h, u8 alpha); diff --git a/source/gx/images/Banner_main.png b/source/gx/images/Banner_main.png index c77db58ec04d13eec65223a5f408fb3dc3fd6474..ee11383b8e95c278300c3c5b8a2915a044db9eb9 100644 GIT binary patch literal 23123 zcmZ^L1yq$?w=OLWN;gVMHzM5<62b-n=|&o)yQM=yY7z!-OIiLB=XDfk^SklDbX;H0;&Q72oD$HsGlAW#f8rT-ojbwizbF1i$a@=9JKYD3&DToAUn(SF?Fm=`g>AI7S8d4HQzX) z3iS@$D>!`Ac?M!Q?eTyXDQbduvKVmCFw875`&zV7IKJ!$YPIos1QaTG&*wJq$N|_d z5ybq(LVq2ANm${W;pAF8F7__^8Ne)*JQgZ!+A9q6k7!8SC`t{4@7M+@p#u zyLo9$elpc1Sr~E1_^5A#P~ngR_)twAO{!Pev7xGV9kUh2Rb_3kTQsrzogx8cX*ve!Ek1R}X8Ke#+g=zMx2Np9TT-O0iuBKF7M2ETc(1stqo z7@P{V1sMsHv|=p&LBZ{OT$bU-k00k{E{59rALVUw?+)bqVpr_d)VALiUpV8h=EfY4 z=QDfp9Wt3N9)D6x9ZqWWx;g#oy6kQ)pbbZyiHwO&$cl?u0e^!!{>;G75Jr@Klmz1TOpTi2o3H(!JSLc8(+25>( z8sA@^XeH~q%rX8}tuOa)3~@Sp_g+Ix74(fVz8zQ#mCCzuAisUr@T`n}D>BAa5iH`} zb-p`MSE}2@Cxo#hUJW>EUJ6t9C9V`+F;stzCPs*>f7RYZqlx3-jf&i0^ZEAL&-C@% zpqS&`8-J0ZdCEn10=v{J*O4zh`pfJ&s9+5p|n3KdA&p9b-rr_&Ji~KB*NDI z4VMbCU(rjM)@;xo@Zr@0f(Nc}0CE6h7ma~GwOFKpFI21p*uE26(?R99*y22N%FRn; zWJcDkL-zVSQgh~pr=i75OC7@?jrX(0@=AN4XZG+6Ma*;{1gXz|UxykO>2GQW8!WV~ zq_<&HuYNbrY?!p*$;&KhSE;W%NEek?!&kwt*%s=+6KMoaezcLryg0-cx z@Wtehro+a4o^jy-X&^RGC4uCES9OAgRQk?*avJvgipPL`;SU`w-K<|~bz)~gWEB2P zjI%ny2Si%c%DS_MR#jm*SzdnkXojHc(6`rWwRW?=Ud|H!`kqwlXY>h(Uq2w)h=dI( zM03m@+&1E5^R!E+_3jin4+K6;32WgatJiFs*as;KJ{cFUyxQuR7b(Ymr6fP#cHI7q z!3J2(>(g%oT*fD4f*S{XI)-ZYDA5k7nbAuVv|YT;_W5PA3<_9SUzM=nrt=C?zG`b+ z?%llnRZ;(f;9w$OnTpr@_MBXM9-${&7xEOcxMC)NNxU9&ZJUG1%Dib&ma@!oSCk@A zInK%`(n;`%w#99{9kNubxubLEuNQS>#Pu2*Tt9rc{qs|SU8~6jD)%>yz5*LVfW8eQ zzOp-6>y~6tOy!XXuD@7NT5<7g8dZA9;cqp1jX)#<1=2_$LL}-v8y_La{^1<6HV;e+Yd86LXDB7T1 zI_Aj(g6#+Tzqakx0+2C6BFP1;s125UbCMQYTU0>y?n1=0odSsorpIm%Kj^z@`nd?J zo(GB(0&sG@^Xn`&qL8Mfwz$02V{x)j?I~4jqmx*&$T$VV!~lqD@0OeW#lAY%h7{Tv zSM9v}=XJc)pJ*Dkn}iF`Sj6`|O-}e&VE*rw6TEQ1dZ=KRHz1GHRYY{f*BYPaPd5h{ zkmnKja0S@10CZ=wl43V#@0Ql)e=E(k9F_L-mIEA6j zqoUNvZJgVv@RcGjDQ4lbLC{U#*P^fsq1Ho7siTwE^}>`wdNIe(MLO~W@uAG7x7V#( z2OB^129w#r^}xAuy{htiS};cj$uA%x?)X68Vm6shAqkU8$n6-8|6|0JW)>q;CCf`W zuA(C6xs8hq@gzEYX=#MNu41s~YnoH{iYH?mbQnq(a5{g=m+(1pqyRzyMC%L2`eAfJ z$G;IL{DOo-)77Wmii1?{$1>0m=u~R{-Dx~jP+2t=Y&@bU*I$3sde>72xWNL0v7Yfc zeAbE)jmAP-P(Ikl;~+~s5T(BTwmV5OW!Rx0JRIL5oASPCUYB(n1iD70TAh%yB1_e3 zgT8@e%#Csy_e3^ZPUP9>)Y^EFoTz_oa9xnUE)}p;H z$XNv>AqRSl1#!A~O}m31lIT)}DW7&YI%6y721Z3L7(+~?Vjo8X#GJHv@qs?Mzr&-WlauF?^ThiEzo7TsiR6MH3OD?p z&XDyA4aUk>Ue35rHD~r0l(8y*D>c4ky85Zyt@T8aDTGlHshpz{eo}wRyb9{30`Um@YJ8h^`-AqUDB%6|qvo>_EdB7=wmAXlF-0qVxgx(*XaV%6c}6BKN+ ztHC?F?U2;YbrzEm7sq;NYWkoGoG^SSds)&cA( z03-F+fxgtJKDA+c0CEC+@3bzRdWNNimRwQ|%AP!qy9xc@!jB5Z)rp94+PxOvO0WL5 ze6{2X>H1CHzN#fQPV>=z{3-Q=l{nz4pGeRB(Ie~#K%m!JSd@yN`6yPSni0( z&jn`B_`PBGHwpgNHEA(UjYZhdXKij@lihT8%7?pU1$1*$)joXifOsCYB;#7V2)INX z4{#YBlPMrXWitS3zx_)ZJmLM&_1%1MW=d@ASaA{j#QgBxNu38i-5?iW+Ij3#nFUZj z=J@N6?27L-I@rGqE>(K#+8&@M0Le>>h=}N}2Z9#+IUG9MyN;d*3>04%YQv5ow7I9+ z_(rtL_j1aosE8~_QzHOT{3_P7?Jr-X@yhww<}T`#hs8^`P_jEJbT%}Jj6wJfPna$1 zDO0naGF5^uETKt=>ij(2 zpY+M{Bz6ru%}~L$PssqDErIyNGUr8dT)eOQ$)?}xwU*(!OagFD6n`TZ+;-%Mr)u$v zi?zz93$G8x3Ory0Wa{)+`542`KOnZknQ zSy=`;A7fUIS+Y_nr0m6C0YQQ+P38o98-h)d%IUN<g?**%ppR{);2%za0z3z}0A#x7fch2S zgOw+63&;j7w2ftr0`M|dWi~wU%$j)ye|*QtE zsw9Lc?V3#cD=`a%tyVt$C0|cr%QA?6Brr0&>iwQXZu`9QOIcxaVM@pRCcI-$+R<8xsC824BE-fT5+)l8SV|G z$4>TZ!UzHAN;awc%rYJ$1-Xkv5`j7hdVFe5_OFR}=MGK6UiYS)80BfWqJW92YI%xt zwT7K2oNRzArJryOo`zM}7wTtxxY*FJ-m6T!b!vQPVe@>LO|w^FKbr*oKOml~oHE)| zde`85&vBO3`nrY6>$qKxjL#Z(9kA@vZO{8G=Dt#%hRI)72maG<4w$R0ikm4?*o+Lz%j-8f z@6wg_{DY8zKyq%=mCnP0D}4(K3twL?Iw||p##Qf&HK>+e;mSo^-m^vNx!Ouf)U@{B z-X_87;jSp^x;bMA1|QDynHzKw>oD+NOR|8mbgmqSOVG9=H+~E;WV#vs0o*(I;NvU& z7e#`epj_PClKE~MV6%2j(Auvkxi1~=MsiPKk_??uk;HzBLwnzgt?>Aw_U(Da2-as2uKQQSSYV=)ZOU_tG>T%@P4cB&$4=Q zy_1+4B%V}}GMo|#RFE~tCQedJ-3Ecbw3hOq%JL4rm0NIBLq&zd>tMFxJHQLt=fpca zks<^F0JlA5rCreI4Vl$lok@TEY6I}WvMsTDggRYPy}gNII&l;F_APUo>03?Gi={a; zxhIOEsPRqotz)BwQ~aZcA4c|T$%0#S+7?0y30aUiGq zWjxmmWXU`RF#CXRX~nC{qH0cYiS;F}bF9HJQR)%VyHB;&T0TljN)QyHBwz1p67b9w zV0>ds{SxJ(t?T67lK)=@edjf8H#dB+Ydri=2^8ul*yOXGRYB+Z!$lhzK!|i1X*-M{ z{){unI}ROb8xf@%ZVa0iUJf`FlDb95K`8=qeVe7uxb>fmkQLSVcIx#j=676-;Q{T` zh%e?Be=d!Q>Ha0Mr6RmFSYDN7u{w6?wr%&PgR)8)Z)@xyZZF!SsnO@X<(yHUr@IpS zPaY=WqP`7_oIdHqrbT?MkjzFgQD@gCVhUp0e^$(&bKRz;M&72Z1F_}_C<=is=>o@3 zj|wfZbtvQ&j;O*l9Nsb{iwnI5c@+c&>nQxH2)rN7US>wqxrSjaX2&9 zo6FMNYv#kLiC{2TzuEiF1sUpNA`3Jw+b?CZd|ee#ktk@J5yPNmO^2ju6Z~~{a?+BE z44>;<=N5C~SypXb0&{Xg9tt#@cAvHWbN=4bB?}`pPUwnryS0;dhfQ|(0EJtMB)muN zMZ&iM7ABCPZfc@K3c#iw=Xyv3be37$=93;TIeNo~E!}TPnl4(>m9KIO(B=6}X|#d5 z`VYx`ySHxbasmsl@j99=wg$8kauK)VmE31IlqJZ`emGCb#2qPC{`a)s*%K3Y#?vV{ zIypLeXinC@FBXMF&Ic>&;eQ*$ef}Tufz~1D@w?@r!zK?J>5?4s_-aZ(1}LDD$d5mEFPVDvgPj zOtxpp&#>VCP`UHnlF{4u-I!#PGdz}y$5L{&)m~%4R}*iTd72u_n(Y9IaNFyGbNS)e z*L!`yMC($h7i2&q!RXHKpHnoR(5m0Vm-bAVP~*b?mk{J9hQ*2?{1X|*%p#N*ne|zFD zpB~TW7U?Pb-l`(OoS&~4%=mBQ{Es&}Q02}O2v^{%5G1m_E@uAQtNra1{$b@$RsqKD z2F1jc5k~;c31_TFU%gUCKE?mL&OaM+?&vLWZr@4dl3!6C4f6|r5<~wn=AUK$6T9oi z>P=bO;W>Ttis8aPh$8=&O#+{pb-Blu|HXR#yR$M*b{iY~5-ItJ zGXH;19CI@1#@1SY_pCQR__x7)I>Z0wpnqIwQD4wEztO3ys-gK;<+X8R^w}#?a%eoK zUYOBXcjU`1Vv47IIfxQTj}g6r$#oaivGqXs0X7n%hk;q&Cu zYPd-kswZ%Dk_=5ZQdcsv;tP~{Kcjmvxhlb=1Vse>+)?1xD=(MqCX1x^xFVC20UM^j z`4!B)DQl#ZZp)+9H!{q?>O`GI(X@WYKQU=fA5s}4{4xX9iEiJN_VMJfS6wqv_JB$u zJrKS#-@xey+=>gYW7f{ZZy$8Fd?SvOohft1Im8|nkW1JfMj(f*0&6Jv1Oauf3T72=-o^alwieVqiE6U<}qp20R z3ONUCEK1DQQ+3Hj>M>%P&_LsqALZhM#QBWAI>pA1$3&*DrVKee-)~Iad*frk9d!YE z_pY58^{a-@i@r+LCbI;O@#0aHwY3E2D`i)RZ@@o|cE$_1FWrBQ{YmRRpp3)gTI- zRk4y`ZBJEkJ+7asyRl`1mNAlSV z;cRO-*ACLk(sX#&+_N+WmvvAeF&#ZVP= zdYq8G<@ktW@57QQU}t>#e1vBbTf0@wilh5HtETj3aa7vJx=SanTg*-8ejhfl0E3ZW zfVu|gWI^*WbmN>HQwDF7;c~@+|73Ck5~Iym4;{%PEn<#-ZdX-#{@tABa`^Y3EeBkb3~dK7^qP^3D+@3gaOb4I;Ya{rFYtAN;IWPR2xv0_wPY3<;|0Qm|+Pe>hrl=^3(P!iv)#gUK4RIvBM(Mq#`VC6%Yoj}6rNi~fI0}}QD|kwuZ4?wb25vpc_Zt#xnvjvd|@aHRD0?+$h-P3IOdfqffEdF@9C6jNvO_K$q8m})=_ za{W8X?>EuPnqWPA$q&2CqTNRqD-MDrd~Q;cj?9{+TYcl}+0YNFV(~eHYG^mFeW<)q zHhNh0XDbpYn#}OOBYM`oB*VPl#c7Lb=qoOVC8^1V6UX~XM}(|Bn)Rv%vrl^k6fyBk zX*yVJCj)z)F1Zmp?_^3}5uhkxzwRtJRD6vnqttE^-MQ}KGGMtn%#WaL?|uh$&B^&w z4w9*4SoD4MPkDR0YAki)dxmaGa6Ccxmm>iBj{nShPU9M}ug`u)*oxhSEcoR73QQ-m zJkoS@|8<#U7jCHG6utFq3AyBYMpW)7BciBiQZw1%D&7Gkt19k%t7SH@~s8=);(sgy{&hhG+dA=gz8Knmj^}u!r+4fo8)iOP6Zrfq4 ze7vH$Z=so~+3_V9VlZ8zRiE*tYc3&nvvxog5$w&aKIt<0Y|h}?Ly{e7M)iIkHugH# zuFYRPk)oXt9M(J4<$bkS`gw`#ULukU1RB&ru2l%&bNp!N^RD7S9i-EMI1?EV6X;p% zxOBl^+b}fxxKCiKXOE|+sYX4B5mKP2Wj;RgxqI92s5a)^eq#4LZ?RzWWog}z@fN|v zch3vnZK)A8I?Y0}}e`&baa9)YOL$jxVGwePO+|ts=djK8QIPV=)=j&bpn&_(r0JRB>^0 z=&U<5r2d-6lQ8XOf>_tAp1C({PB-az=bcVd`BI(ejYsR=Unf3>YmZp))U~nN+;_Cx zOgGKe?hf)Tl*)-o$eXQ{MC4VM1eAz{?6p5TT#pM)c4|Dpb-3IZyDLqeXqGH}`(-$B zjH@CUoiexfz9V_Rk5|p<_D$IqebQ1L&)S3iV}-Gdu@kMDqqX@?oXsZ*bP;f9nq3R? zn!{&XTVFjdk<$u$z>MbmfyaoChu0^@DW!Y^%1~K8Vq+9v$YXoNQ!K*Uz%5X)6Qq9$JU|ijn-! z(?&e0VxU4c(U7G$Ql?HQ(BanL^y1i>c7?^Mw(GlhTY8vx?NmRXh3$nKD}Lu|FbHs(p?(1CvYmcF*pZ(N@dmBPvw|L1PZcc;s)8pr0+B$hTEi?`%vZLmOgl~NPW zEP~a(WS*_pBs$j>Vo3hhix&UK&4V84XXf0br3O#-h1wE^ms$%)FJ8!01uw25L+v6+ zZNzdLW5K3D!P!xWb{nQJb&E_l2!!h;w-+J@_9QjE{?=s+ti(O1hBV;jJ zBBBaiW}mN(Z1jeg^R{uzXK+g`fj)UionnJ&=# zIC{T;;dOj<<#xJjUVo94^jjPY39}t~RiBQJuNe8UuJRPK%1poW@qR7;`4JHzbR)Xy zFb|+r%L1MAkWd>TiM#2#velgmV>nFm*uhSmWwMi->cO%uD}~=Lh+=Z~HXEwt`aDf> z@-#13#+stOfDV>m4nvz*C^V9%>@nFzK&mY*XSy92x`D|GV8%lz} zmcuy@zr$|zYtQgSpd}qOe`xlWoy^Hlw+?+|xHMIY<#xN+lHO znVBJTFJz6q>E^s|D|eD~ast{!?{_JN2z3fqJ^}ODk(Y*1%0JdNLICV`hDU6$op;z~^c(t=Mg z=lZGTP`#J-q_%NyWS+$WJzI+xpJ$!#4`c$SxTryOf`o3Fkt~Pyq8y8i@vjBO_a;CV z{UQfQySVeX|aRy%;!LvhQ@gZkzF?8kaKYy#1p1n$e;(u&97~{L-DQ*6wY!^5pD7L2U(C zN6pchp@r*?%gV$A=Y%`)Cu6vT;rK`xv~g=;=B(To7C5<#XndZ8Wv#C>3i}EL^bpPA z%;y)ay;D-@!pPF9k~2-+NxzqcJ&kP3dzT{TUQkuR1T^*9)0z3ZaVM^ib4Rbo71(3v z?9>e)HTZuXuE6h}Bu`C|o>j?bUbzFbay{!8v2mFp3Z>M#OdUK*!V z1p`t}#?Q)}ptbN^7T=ApVKT5yf_(Q)b5RC5I^ed47tguR>U4Sio#)`J)+ebP;h3Nw zlViyiHW!v=-uq@B{&35^=Wy5%<7A5gH}Eg|({Kj6Las?PK5xwWX+$7LbSoZfvn(5g zX``&f^@3N|aWwsqFl-y5jzp){&SzYgH~uK(J6!Pc1DB6B3cm2$%y-m6gNd;!2B&lF z_cgsPZ<2-1SGa~g;62=88T5LPRL$YnluTJ=D{G(#G{jvc4xnS)VdM_hY7Y}*a_Mi2 zs5@Abot!v8*=Nxsx`%#cOa5Y@t?gCl~9>=z^C%)US4J@>(`+cK5x zb8bxTlmuAhdp()5afQ@T+MD9wprGrq+C3;7Q@`uC6Sh(ErKJc;!!z(zilN)obhBc};B|f*<#4kWwXjP%9;gS^@ zQ9UUl3p2ICp9X(rH*{&0WbZ$mJCMbby_=5fE}p1*5k>NoT-}1MRcqiQZrVrm#bK=GliSbF;SFSD*lFdA zHu?;Qnoe#DY@8bwz3xwBukT?6mGGy%@4KedLyN3py6!fyw>k-YF}y|APZb&-qUiwn zZ{Lkh&_}u*8qEg0#;Nj0B#Ntv@=D$^8=sFeY}jaGs>^pB9^V2b;pJicW+K_Oca`8QCOsari>ZCE3D6Yh{^N13vioUazE<e=w6$-P(nk<H6EN$3KDD(1}In?UuJ{som z`x;Ct${V_ynX5;C$dPH+wE)jF$kAe^vEU*En`~qxr*yGdY!LqeLgq`moEZ=)wOv*$ z*3|s_E#YS&vex;oQjG1;q=Ldi=_IVKxfj2*p*A=H3q9{;K_J?eRW0>*!#gqKCfV7S zJhIq_(b^m1p~*l$>l-|0A(iywcPtkt`iI0FsGXg!7xYf$U^|X50!#J-`#0jvR91(2 z($8Nblq0o5g81-9FLR7~qWTfT`bbN)8*-pFn(7D9_?Jf!K9TMhivrdQ&6%BoGcU;^ z0qg%1yDCjOCMJS_uEz#kEpYHve(C!M7n?{*wHI<7aVbhRo3At7FQ2JWeTE7iMd`8s zZWBI3sxs4+Gk%YJ*>&EBlUVB&0G2(nidn#rI9I3fw0Y^UDZ($G5L=BEE zV^r})9WHk)e_S3dAjadPPr4j2<+--SQILlJyl4Yyhn&Cb-|4;mqA$hbGUlr+qa#ir0_&zD}C<|SpHeDXr7$bswuK)NNap^SJj0emP?!+d}rTH`jz83xB z2VWZSvo^#KEw$%u^zK~X&1uAF&SmfEvm-iQ)C$L}9v0RbTcg>)o2+Q zPKv>gEJhj7;O_eLs2`>#!7!+UfCFvbNln@7#4(TlU2jIwiWtvB{SiB#DK44iUMlZC zcApC-UfwC8tB1bdtC@Gn##}li9FFKB`sd|JRRY)vbkPIxJC{0e#jp#Xrf^YM|6^y| zw`JI6p?svNb5oBG)SHlbsL5v4%NAoWv&X0}_GROj`GfwFM@O5|xQ~Z-`?^N$6H8R!`!4Cnwl;ZyVOZ8Q2EmFI>E_V3KWDF zadU@XQU$gvYCMkP+b;bsngVmUDw)(CoiJps{Umw}+&FI~#_XYVctm@;`RKGe!HX!4 z*be@-iiI7RTj`4NbaxRqx4p}6H9^3=KK47ed0c#I`;?}>G;nXrqMx(Sda?d{dF#C2 z!qhvDEion~3TisKV1C#&A+yGP#AGB4ilP~By)vcgJ2(KM3RxC(U!$F_4+{H|@S&1} zRMG3E+dOiFN>;obpRI+*kvJu>Sj6P2%t#$XC+Nz9CPxCDw&O|7-J3B!%3N|=943Bm zc8g7#Uz4T=TC;Z1^Muxw+;UWsw~a=OTST97d}rya90~}olWq3BzjlbE-=9I3e^1Zs zd39jc-m%~?3+3VAbFmPHF8;~$XnL_rN{WmIlS&Vm*rbx8 z&MAbjWsN*6d}r4ZBo<~>!y~GD!Dn0S9R`zc9p4`AvnXV%=*ouIEh>7rP0mffWz2RCW7xiW$@$$s zFqG@6s8|B8wtz`pL*o>EO5py2H?pZKLzJ)4Wf2QCOyOW?jea2lG{rX@paBPa3_lwK}MKN?q3b zi$Kw+oVPBkyn%?c7N0@oY?!hl9VahF1aD?SD7s})F@oHyMRGd-) z5yY+KFpPa{y07wi!dw8|NHk3YzeZZ_CbwLVEofG&8o6zhtTr0n^TXTMEw?@7l58Fe zAjPdWA3U#cuuv9BQb~)R#Fo+h9IFWxB~;W<%VKjh21E-9fPCGmE_vz-)jK$~*ZZyeTcj-<#H1=Q~PXdahkHg!`mSq7}&i z^?klyTqNI26FdZ?kvzKicBhQ{uU^$t7N!DRyW30?j^34jnoH)}l$?A8)Kg+kYt*Kz zT5tHmB6+aCu~BQetoF3n9|UO3+sZQ9e%d@!*S>t3*@Qn83_t7IvXpMn(Yt-y&({poievz3Q&HeoEXshabR%3@mPJ>|>_97cBg`$JxgMk*Y3z z^o7I8S5Udt9=?HOaP-rebOj~hMjkg;Orb7KFBq^MwP9!~q6 zcc0|XaWXFlDuJabo(qqdmV61Q`d(f4NxAXS@7NOOpD`$-F2{!&7XQ6`g@HZv|84LJ z1oYe02|6eE+`fWv3FYq?%Ku(u`X7TwrEBN@ProZmvI?x4&OT%^1B z?G=;WusB?f8Pu_v3m*M0LfSlPOC_SJ~Gs{%=9}-7#}Uoz_t}C6KVSt7o;$ZfX`MiL@kg zd=_{4Q$BpDL;maAJw`Q#U!Agw&?z;A^OeYZ<_fR|_AlxsperoX*I}IKAnELeLP8+N z`pNSzzD19V;8tJS0!akO(X?}ZK!($eP`)(-1e=&*G!Td*wdCVEx!a%6a+TK5c3E{k3=I*h#W!uFE0_xvD#) zzhw9&)P?t@+y?^}Quc7jvjYG9zA`LI3Tii>TW`G*hZ7#2NnrBzm1Qu6g%7_Cr@S|~ z=oTJLE}nx}v7jgii^h=0uwtHrcsToPZ2QaSvkUEY&Q#X=G_n(qPplboCIVv^%TyME zWV>6ow!eW$iC@`pcwOz=QC_^2_jYkO3aDx&wMeC%GFhcXkZr6C1(ZOvh++RZBa95H z)hn(90c?d&UMs|JX`)@Py}K=HjX3%^W0L2LKJy}BUpG^J8hP7HNkm^oP|V8dJc?FM zbHB(5==c2mYgR>)@uoni0Zoi;vdbdP5!DNs+_=gY++U^$o_`svgxBKBLb@z(x99=H z$0Ejh-S><>b{4*aD2PCe55K?YLqP(K~fT0)-2E z9o99-_quSLg5K}qr5+9Ed33RAHr3PL2K8HKS8l+?w+8_lT02nCUoeV@p`S-O=UzXg zl-7!6I2LRZ`4u;)VvHC&6OOmqmu6GuuJ%rBe+g|x@}}hHljXA2q?y{}BPH8Y1<@G^ zHro=#vrGU(oXYlh{c#z9O~BAMJZI&sv2TYv=tuQISR+s_fL4P2yqk1U`NUrd_{o|$ zwa|#_Oq{r2;87?p_d;ZVjKj*AE_W{718WS+7?U^t) zpd9J3l8=FYwO8Ctl)UMG0D9U_Bf!lLZkYsRO(z=q1c6C$n#IyWnBvYG9`)p)%b1yU z`rJ{2B4#Cv-nOY0`YH%2P)6T)?-@`Za|VkjzuSFp23ajA>Nr8v;Y2<(1-xFe7?=L$ zBk|t(+Le1n55tNJUyx6bn=l)GTMT#qc<G}Fa zV+|aiik)LQIUoa7U#LSvBWMS+&l-Ws9qI2);`4~9D@jSjfJ0yu{`^-%S{jFz_J|-z z^_9;ofE_PBc!VPCCcV9iONp00YL(0#um)$|Jxp=G@%3)Z!+S?vHD*jIj!vc9;eGEz zRN;DbIL1LN8G>mzAIW?T zwe#tZeJMHHQk+7-tZ{tYiBsj&dzo@)2K1qZ`#9ZDtF`|8%+=`bh(0nWG`(_WT>N^D z)Y5FzPWST@hMR3s*mPx-s0UED>b?m&GinqIZ#7DWVq;`5v@4o9jPngJGu5w!lU#f2 zxlq0N{nu(e5C3LPJh!V1{_jFx-tw9=Nt#BJCx*`KZ~cZnWJ5j9$9wCIPjXVeu=%

%D@tUb765LOu9ZK-^BH)hMOC<|u*!$e$J^t$>~-TP3SCS8PXhMb;;H!7e+;1yq! z^*uz+=bm21Tz-#~+b{1Wfu4mdlaEa_Q3rt&`E(OAR@r`*b$gC>fL3_jY!pb zILZaEc!VO-BHx9}SGEoABJRcvK_i3B_X@{1LY!A$^k8(~C?E=s@}z?3buw>YJ3ont zMYzCiZI8*nZ>EXgLTVl=>9%0x8KT%A&|I^Fx3jk~4^hJ63yv93GN;Y$=KUpq8cF4QN%bWA zT~p2D`EuXqs)vbH+bWv6*ztV2`oHc4H1!oWEp5!wRy^lh@09cOIhm{5WTPkpfm^EH z&8O_``wqwf(uoP7;W;DQ3}E-@wucLwExiX;J)d3oE!K}x4y)5+jx;jS5+IPs-9|!~ z=MF1ByTQ({=U&G#JMgoz(F2mIlPPya7hi-N)hXkxEl6(7+h4gHE&BIcZ%$}@VbgZQ z;PZSHy%Aa9c(KzD(HHhVo0FAMz3E}E!5G*XNIu@JS0)B}GV~S`t)8Q+O2eh?ca=l& zN383;<@ZF%kz}35F(P@wA23Q_8xxN`JNFLO?2GMnTO;izm1Bz^XFh1g_U*;Ss@(e! zvg;`xMPi=zMw(xOW?~Z)NqG6~^kDU4gZq}#lnG2s(Oo>Lq@-}f9Ms7rB}qf^bR#3* z`jMY+Mv@m|J=(7~r+w!Ke#BF-ekrcM-GC4djwI&k{{<*0SjDmgsd%F^GM!wS0Qdyt z;|X92%J0h#ilMZ&uo#isH#zvy`J9L0pkkWZVT;vbx3oSr!GqO&TcDKe8{qVJ76$Pk$fB$ z3Xm>1@(P0~LKj?_Ubm3GfdP}#jl%lWJ)q3fz1AWlG}$bQsfRV%0ay2=4gwW=qQv8| z6p2MM|NN=sI7>2>c~)!V412@MP17Fo1+1o_*ABeP4VWTr1E3O1EAXuli{SZUhLu#@ zQ0pFPl9wF`9He3OmM^AsbYDCPGaGu@n08X1T5rC)1Rz|+UT2J)yi)JBL+IY^^rFB9 zHaTgLknbF{v4$6JMPHDd zns%AFD|gmYP(1;y9jqhF^Zl1@G=R;QKim=lkt7aFImvdcx;yWNT4%u&NxU6z5w#7j zR}imcF+W!UXAdA&P!ZE7-=#WZ&k0ALjm?kUE9}gt99Uu`PJ2!;F-a7Wg$5Y4fn&gPNjAox`!G~+^j%Pu9fa}{y3l#J)J?2t_TohX z{PhhxEcDA~(RJ7Iht&8#T((|NG-Se9|!j&}Rms0_NMhmj}XV*yNLW3_1;` z;7GE3Zvi4An~0RH&p_U1CtGtEa(q`&`PIX)=4gosheO8qt-`qX!;5+nYzn^gIn5E1 zh07cj0q?s@%?tvv7#g*#>zDZ@ZQRTe(OY;q+y*-)E5{{mzwLD^Qwm6y52)#~ovv z0p6}E4A=0E5=}kh3)X-aiP^3vs*z5Op z-}>#hFaKuFoSEOuIWza(nVA7vzweZpFg?3oqoqJaA^XMyAB{UUU`G-esqI0tR5cKirbwE|Ng2;-0R~i?&|Ofo;76P}!(>)R}8bwRXG@ zTmi@1CZEiu8G;|c?l?`$XRE(B8Uy?hAiJc1USNiKt-1b+l4^0lqf^x!_5&5u*^*8$ z&hU+JH>WJ>%$vba`u7~B6#?k*V}os@0F(jDLK5-JLi)wFR*XQN`XmFcMmkd3->ozs zw7CgMYWbE3a@+3R@R^L~5A5p7f0_!kL;ZT!sksXedDVS(mppitlF}=G--g%x_@=19 z11n1gH0`fbgb4(SDsWr`wtME{K~t(OE<9A1c;q>)LFafdTWnM%jh8Q+@!lEO2HZBa z*kUUYj4{ibhuQA_)z}(ULto?XSnRuZ?~Fx1jhwoJ*tHIS^yJ-=d+V-_qV3+Qw&BDx zC1J)hLl3ExD(B@p`9X>3De@een3~8h8}TZpZ`-psF?zn|NWPa?RolCrOx*H_N^RQT zDh087YvMmXAdS;yziy1xFPiQWx+VHVGjRmMZ4&_UQF^p&J8DN49-lR!wjR4xq61Eu z5qHH2r(u4orFkr>VPRzf%I3VK1)Op_MN60CMT{5QVk0Zyd-aFOh2lImnJ(lxHpf`a zltm5V2W%{4KMOR*D}punGSEZZA@Qnca~~g^{w8a$qLMTr``x)|2I)9ha!W+S1=CA= z&D0R*NBb3$)?!Lne?{|VeO;uM0tC>}IdAiR*s5}hC0I0PJuvqHDlf65L}#(*DCo$@ z&_gD%{nt-{e4Py;hy~F--pArLu*8r~I>av|0&}RYmltQ5{cX0XV%y>thP5^7| zQ%K8i6LUgpQ6@J9Slzf{KQqYrhag&}Ps$p2^ExFTfq{0e=-RK(Xk-6_x zjq0COlXCEbgR}wegkgd&+`Ve8-SrK<7h`c*Ms4jow*pK;pB=b2M^nL{mU*GTV~26C z;R{FFw}9TA!^dt*+Xjq`z)7>D3IrCr4=Q z(1Qm$tRoDsafgq5o82Z>Z%nQlfIb!yI@XP4r~wGyyEI3e?_3FORBwwG<}=|9Kqibg z{ABsAr@!So#gbiojzQcqB*{viKF+eruEc3+{TluY&`X&4Irpk2I3YsPW`Dir>!Kq!!;Zo~rkfkr<3kQE)9c#BRE!>?_8wfrx#5ePaALYm;6R zy%ULR^0}aJ_^6UhQ>1!@u)_`Ri#oDSmRm0+C$HvwYa&(Jz~N(mY-e73PM${!cbgxg zijmemWChh>`r!!D%E}@`114JH(}rcwipOZ}0T@+Yarut?pNeA2_Lau66*dA~TwKRX zFZ!3|$U7kGq_&FsO?qVA!c7W=2b)o27{dFdy!@3zPm0%D=;6!ebz>g<1p2!i-*-~) zhs?~zx{9g;UVlTK>~l5p6t~CR&}I!1y}mqK&8xNf0b0YYkW_S!BjLJA)qUh?pptt# zL4tV7vD2?j!8_uor%hqJUmL-m4BjQMKfoYYP#0v@PL>_l?GJr=3|k*RqOpBJjMC7m z&d;|Usd43@>gh=za1o9T@29}xrd-b1J}=}AQ6E6K>mX9(p7^%f5N zxu266zR=xQMofB=?xKvXye8U0#B+q|xV>siBmX?w>-Ws_1(5uZT^jvFqzbCBIf3B; zx(v@`xR5P`VI?8{+{bJY1zJfQDCZtmxIK%rtk;<1&^I==%{3r)KYpK_VoGhyrTW9| z7_he_fnC0ZW~D;nsjgglt!Y|~E{pie%Fydp=92`o%L3ixa^?!B{U40^ix~ey1iiUe zf#|vJ@=anG-*_y$7om1Rf@UBmehN)A?h^+KcbE9h>$@A{Xs;E)@xkLIDB6lir>nq) z+xFvP&m&`_(pM61y5q2D6N+?QWJiP(>-f-k^{fjWzPo0l{`A-2(>-6V zz#Vgo*Vz`UABMwM^3~&nAq&GE8<;m(5)S3C^2EA2OdpnHma#0|t8l~wSPr_c6@1H) zjsV2R3r`+e`^_wVKm;3HF$O~&1{pqnOw+O)Y(>@rV~X0u>awyS9yfPgg3|va_^6LFa(E9MU~pT0;*W871+s5z0|l}<&MEYY;xlrghZ z3R1<+ZM)UUqm9K!N# z>$`^v4bL;{M?|x{YyJUd@%Ci_%k@fI?M;wvF^!Ftb z5+=2H`oNc%=7ee3Dd~nwJM=B|(uQR(JO%NxQ{05rA8Ms)%ZT+Uyo@pbkwcrAd5{U0 zUbdZV(W(0GVKK?_1UG#NK5K?Zi>n&ZhDb6%e|oKI@%k$j&pN%wz>YZ4dY zB^~GJhiNVN?-l@=$2HjQX~2&h$n;N&5cf)4mo4MBr$vXhMn1Q6jAYqjvrEaW(K$Fr zJR2Qzf4_T#XwMOQGR$qLuEM2RWe95=oC60OCQ$6Mcl8xxJo<3iYJbhPp|fMy0UB~c zAXhFLuB;R8vOWTNHt71X&}+OfS>MD%ZbY)!S|J!)71lmX9`ITp=oV=&nYD)R3LYT8 z+uKej@fdHw(q*h%R6K#Oq-4%}0jhk|7fVypl$mJY@mw-<+P-k!m0LhJOGKc7j(>FEnf?*< zmDH*os{49fA$oU#<@OzgHeR#)f6{)wTc!C_dhMT2|GgmcYO5~-;0%v)3W zI^*{7+A_xV$dCws!+6o$f`XXgiuwxydn>W=lG;Y{iS?5rdu%DL<6?3xTr8Q*Ul_^- z*25WE@}`Eq&NSb~y!Atxx_cU-2T!GqJO%UPHmyA0M(!!)YMnUSpbodJbzgns_%fOg zX9wXDA#-7=g7pWlBW5FoQi(q(#yF&uquX(dXpTz!mB0sFstf~oG+no&8)rP-!b<0V>|q zuXPgs)>G)I=gK&Yj`67KvXb5kl!ymCtad2*duA1}BeAd1#x z8oDhAC@*zzIpg@-@{XU3wL)!rW7?cVyT5r9ND%CUOxkhz@|Ff>A`-{!>f(68TXUFp zeo+^CA8_72?|CY6WRaLDH3lO8$kOVPa{y;}|JZ;s|M>c~3bTYW?aWt~mzi{nl2p9^ zxc$~NpuAbL#e%$Emt&U2c5@S|r(wHN{Udnk!OacVoY#0u_gbbH4gM?Z85K1>g~{CZ zZ<+?wGT;F2>FVh@GYs?EQ1_dug+0pd()U+h-Cqmbrz*DgY3!zxg((PFc`|-h@L&Jg zT*f2y24U#tN!_OJ`4(HQwBu4ygN_ycvnfgqRqm}WEB^+&Jio}&&w+eRN8KaAzI8#J zRbOu%xkNpqTUzmnUh}jGFAtt1Fn(L*tQ@yOeM-jT8pK6G9PY|F&Ebjalo$ko)0WcW zC0JKa)yfv_8Sj=?nBYbE0JlJ+&QoHbbfvp6$os~ z7_4F~Gp>yJT-wGYM#pgA3pgIPg(+_kb~!`{`;~MNK=jRAo?%O7jkDCE-56t7e;tLh z9c=x%tX6S9-wrVz0DH$--(5s=q9!~0m&CidfQqTSLLunlYzZwaVXC2N|$OQ!wjTgp)sl&x=?G# zxf9}w+l+N}n-oSOwv9_hl}l9;RUJQURmeEZ)9s`pwtLk@9s@D%R-tsvY94;S;@2FQ z2-({@ED)HJ(mt^IbXVFSZ6;>Nn>Xi33zxvI#?|#49a=W&JtR9CH5+NmFPmc-?mePY zff6R%+IQ^@q$8qH!eOK~DO%O%Y1w{}^yVdLmH+4NkO zle~omy>?_ab_0<07pWED3 zzbybnH;}scplZRbAjLP=4Z{2HZ2ltVo9@iwNSH60g92CA-&_2~Xt;AbVMt8yM#ux{ z2`7j%E625>e;|D9rcqM-x^;jHylByK>bb1bZ(RPCpPf2fYCJKIFTA&@q~Lm(xK`|M z692xxN>j7|Sd6!cjf0K%{lE174|dK@vIeiuAP7SVPCj{VVWR)9elzzvyM`<;3Ma4n z#M1u|F&1%aAsczolZq0UM3ZIpd50|nyl*$g$z)NHm-?Ch=Wc7PH z#qyOTp~f$KgUl#fZKXFO^xwpPtxQ|pN(hya?^16mhK6_@C2^kTnvUTPEBM9ke|h^6 z`%4)Udx^P~dB9M{X_c3T*W}X`I2!*CFX641tyCc@N6Q<*1H;4M`NNM9zcKljfW3M2 zip^rmia4!iF)=xA*OATbxPPaK+)l_26|4FLyxD(Gk@qEJGXE|KQ+SFX=~aFX3Ht?| iUoegOCkq4+PpEykc_*)f_PwZppV}jcGWMbAyZ-`4^o?Tx literal 20675 zcmZ_01z1#3*9JOtx606?q#)hhDJdW*E#2MSh%_kO2na|c-7rXZHwZ&_=RN56fA_!7 z^WS+yg*mg%-Yed<*1PuMv$CQz7CJFH2n52Cm63P{0>S$M|BpaL2L9fQ0ow!rAUcZ4 zs-XfeFI1y2;CnPXnGcR25c<*67o1oLM-uQuh?AtIld7$WldFM)F-XC{(81Q)*vQ-f zB4zGi>}u;^=?GEKY>cI+0#(BQ;Kc6jmbhmZxwuW=l?9KueDAO^-oT6LFBob^z^^{{Eix;PPA+qN1TA zNkte|$SnC11#-|3ppPwKpstB4BleqB8)t;G-WSqPSff{?Zg_x<-ih?JOQPs5!Pln8L`N zM+D;1SBFN3_+8&=trmOp$;s5(9)0?9QXNXk_FP5h8GZ;HbjhO4jXiqjp|dqKv?=*JC{92Q~qc zX@7&L!gRw<9(q{>e04$Qpb$8jU<2Gav1wdH`|S|}w?{q$fiLi{bVZ;0N$EaGHUi;G z90p;Dpa3@~65;d11S4mW{JnufHA*=F6on|1^~DGUUzr~i9$z98f)E3F1IVA%2m6tO zUibF)c2c5ST@3L+M1t^!uMR zqFQ$JH_hlroS%YZ9`;OyJr}oF*H5jmHRMD_nd(txpJiJl3T3p2d6c{qoYF2KPkr-g z!fe*%cE5IbzRrG~7evO=6yOs>7z4RMe9|bw%fn1i=apl}*3Nkpg|Lw4#ojEtvrOsz zSFA#TagWc=pzYU892~B?V{SL-+Z7>an&T86QpOFel-!f*+S&r{dovY>8GOz~SkOFN zioc2vcv3tO9F+Z&bk{9Rr^V}f;7`IC9%Finwo4_EP^*WmBnvXnK6bS$GPAjWckr2} zxJSu0j^NjVR92xL$^t6)u|!5KuH7F68GIO>pok0j5W+7ssITCjG!CEBMVfCXhRf&IrOnH^?ggj^0+Ic<-9$oO-XmXE#YQkjpHxVzZF+iGQhjx=V7wOx@f ze3n*fDSj~XOv^#eV{@(hi|PCK@2A?_6wTj2M9<*ZKxjE6i%q_(WWoXjw2A{v^z`(f zauyvc^Wj?BHclSk1kRTA{r_jDI-<{eiaxSzq&!nHFfb4`Fj#FF8yhoY*2m>|5d-mf z^4u`m(V5miTDHy3zj{)?P4207$JbaV*1nCzsbmuPx1`Lov_hNiI;%29MrY0Uva-Dc zfDrmF54b=GGenf?uaunmfn};7=)?18&mz)ZIjoGt zueQA0PEAE+w1%EA-I#VK8?!B-L1PVE`Ve%c=}5hM%s}6#$hFpxGmzICPfKWOYTBx! zrS+CQ04;~`DLzqGD|}Z4eFZ^HwaY%YST3Oq_f}PU0w2gu9&~JYkZG1OAc9lCer`St zSFjKMCP}67)Xp#{e*ZJ&zAE#6PhiayalF9~5f2HlynmgbufpN-Kr(xep5q{AJ)D9J zJ--ijdw==9)~nJ9R_%MF?TSsg>2;h!9=AO5X`R&76hMIqO-)TW4D|FJx@}AnQ200? zki=r(WVFvE6z;<2&)284Y|~AZo zLa%m%)An9?c=(nxT&ENS(DSROcr?Jhcu0mWmwc##DkQP6YOH@6i&c$OM*e+^0%6cog#H_`1<2ss}nrfPwb+i^bA}0XSa08kuwJ2%w?f=G@3X?g(EH>Z5 zFB;Zq(GkXPXZ_u9Boj@Y*OT)0J4`|W!=WdC{$2BHB8(Srl9sIh33vv?S(4j-=MQii!6>jCK+W3J9(O)SUkixs7Hd9atO2hI!=4u3orxb3 zyH9GV+sUqp4J-a;vn1@eSvI~c&-nUvGR&^--7Ycz>~_O@KYKq(D3i|6W1C-Aju`HT z3EnYr4;iJL$0!Z%-0`y6ckjll-j{0gYT+U>uT3KvAxs|NcIo>I_;pPx&fF4aT&H?< zVsXn83wjJ7N)nRR!1!4|X|nOal%HV**tsv0M6ed7AV>G3`NPH0i9JJl5+04DZpt6S z^;*#U=4^ZX$h*eUis*V%#j7v6}?1=siXh=@q&8p7Us;C{`yHLmX1{4NqNWL zkQNpqV>HJjpQvXS(Whwf!}*=XkdKXHoGbkNO_V`Z(9qoZ4ZtjZju+)*6}#|b!3tI69HZvwkKud?X$+u4-o|QFYG0 zI$$m=3b}voT<0UF_|C@0=Hcpiy-G2SXB2skG6^DYh6%Bs#N)hBlG-b!=*1vpN~7%^ zI-9#uT(uG>5z~4BT2ba?++0rFRp!JhDiT#!|0|OsI(|~Y%tph?Myc<}xc}QAe2m!} zNHfCc;uj|%d=1J`z)Z7=*QYQT>`w%7*;c^1nl%OwOh3Y(waX2jxmX!0#wX$-gR@-^ zf){=MwP447v4;1_?3Sk|Cl_M}5JWtGOp&#sjt&6wD~)>3;|5m+eHw`N)8Qc1I+G$T zL>-6JD*Ab$XE7NVf3A|H{zMLzfA>&jdn+era#qfd8i_j=0pbXKEl24Aq?;S<1=nQ0?!gmXDp0R9x;zHx-G1ECsyi=w>wDzyAiL zAw#&&#n{A;BHEl(M-TOIZtvc`3t99!9dwkK&G0J9M}wu#Wfz60LMqL@{|xtgvmieS z9PSZ_(%{S*ESPKR{Xr=Qtn3xXDh3n<@)JWwyCw!DrY>bm=wcYFtg!bqQ=I?XA$}zfzY7; z>uOt@_l~cs5A;k-Hjj48T79^Z_5>Yv1cta>k`N|Q#vA?qri=QybG0;{=-1c04&n3s zR@-CWtLPaREOA?zAp3ao+Uif>!^i?YUyLfO@C96!PVp_px5-Uave4+XU|!VEr@xm` z5b}D6#|#J6OQluRNJ|Ra7hdPa1JF}SChT+PNvoI^wnWLZhm=PII4uI;w9l0Sbc7c` zO`V}Q6kM(c3(2^9=F*Cj+20pUmkbY7_+56v>l37D{#U19`elfS zh;ENoC2>1PnD!;Sj>o{j5T<8jjJ$v!i_l*y0!oUtaGJhbLiSTazsnF3n=rCiT{1*)kOv^4|mKz`{kj4?))Kr(UUK&=QLe?fEN&jih%iYD*XNc zqTHTDX#$1Fs$^y-yDxib>%$E%AEEYl>Eh9`oiE&vJjh>rfQ$x|H7^D6qSE-Hb7W_K zoh3}*eR;u{LY{&r|JOU&K%W_i;Eo%8+-w^6e|@ltc6D=X)B{$7BG~?A%R-MUmm6>< z0IK~b#y4~Q*OXNp@>w%^Eu@fo^LcFQmWHfA9AAj3PkK3I2uF%PqztKNPCKr9tA#9mSy z8Djq(|KdS1`u>#ZL#0uEf4ab(*O%ec29sycJJZI!SB&dHEMm#o7=F1X>gPqYe z=tx7YkRed-_EZi^xWk!816K2UT3BxC<*@c8GdH)Zk-fcrMNU;hWp2&Z8IlKf(6_;I zpq>P@M1<%;A3dGTQiyC$di%WAfyAj5-x4g<^uZ|;h_79I>pl9LcIn#LgnI)Eqm zI-w~r&a~XYk51<^O7 z9vDv6o+hJB5^K9EkgSz~WL*}zC<>sIw*6E1vO1C6nljy_rKYB`yPy2&ErP~fknsgG z`Ib+YBa0KNbNmfotnKaO@b#LcG~u~T1;u`PAf3uS#Tmv^oZ+vQE^j5bW~djxAFSey z8{6HP@1msLy_q`aKt=x1^RH}($sj+zhUWqHl)njcE09lS`wrA&O6KO~XAOQFlu323 zo^a`vO!;moiJvL35W_D3O2CT>njf~uD^IpyZ4k+mqx+qmA^&Xz94m|9)}_DqcfJ!K zQt?ETF8hnR4A=%)NVr|y_><@J-kY{3Cma2+usFe*3$J3gwEn+f6^Pco*{UAc=H_!`H8&x8 z!QiZ%3&Cp9&1}ejVt&dlO8l#O9hYr_fWTzBeGi$d_T`^=r3~r21IUxLz<{+vI0W4u zn?M3@6PeO2UF$;9OU&^Vr#V(SprpqbO%Lz>c@Gf(JZh5N?UmzKU3=OZfWxZj>Mpf} zhoe8i_NOQH;K$%5U+*HXBm>1@-DiTbUJN>qG5<5$oXMT*l^s_N$y#l`03jH>_oD?n8_=T{BzJZe73 zov`O_;a|Rd=>cHr;R%+WVm9!b|H}}1%nC!G{%Oj*`$Kyw6;1A_5X!ve=KF}Z<>3bB z%eR#k7}Y}dwWoM=3a^~HAkXBdcD=(d2&yjFS{^@wOFC#28LulQ7;uD`T-w7-po(lh zhLV_~^#BiN zcv=%WkVihz;V+$2Hf^Mm_+4(M+740hI!tsawyrICuF$oeM-%c8;9?>|(EakavmG%p z{e(c)g4-_z^I#{tylOu9s$ZaeovMp}i@io5hRve&Km8U%hOp)Vt$pz29ab4o{?ys6 z3ZzoLJ|Cz*#id50WE*D|@M0-U2{(!+k=Ku*M$4fKa3pKbLKkgn%B2BHs+WQY1qCM( zWMlb?@_mDYgA~F(UQ?e5Xgh$Q8b+mIhOklro(Hy&IJ~xux=$7M^?3-x`>@W(hY(e} zEF3XcMbUao2vSoJH&iXgGcda>@V8o*eG;3fr{t(b0{w$oWsG%-`4?AdGrcOY@t7fl zs5BuQ9B4scHmB2vWW&b=8`mA6akF_wrFBxFTEpYng0@+SO|c#$0moE;P)P@$7P!k- zS1OJl`~^MnsrF^BK0~|{O?aOX0!=QctGk*58Y5D$Ahr$otO;)5jFVjT zByE->UFrly40Uo*RCVb2-> zltVuSx`D*R#8BFREtWaz6kIV(UMdiw(7Ox>GBO;r3y0fJ4P^e*5yZu^dKo!tC9VfX zM~OTpvHNzKWlQPBA==rkFC)z4#s3wrJDeS^O4mnX+21EK_yOqjO8WZxP8&*#S>~t! zz9j)Op{SD7{6-q33<39rI(w983gOaDv*-n&(`H4C1x1jV;USJn=g|65 zEjsiws)iaHMcG(vJCM@}F4;2UK*4~vrx`hwnQ8wPy={PJyTDiF%g2R&r}@tOvDyqe z?E7%a1cvIlDTojw$Y8#v0`Vd+20(5=;zqaJv)fKIgX#RPl@OVwO3H%KiLs@!SR!oy z_ET1+zwIdi4L3QoxN1kk&BmHXKg?z0X_bbChlYecXlc#Ei@;?)g<;rBIIz&jE7Y9m zphSN>*l?z>jVAO6?^Uvx(Mge7fX=Xl)s=5VH7 zo%Q@LHn2`B-xIup$0#0-LYXlEf2+ggfeqNy_QM79<9yY~scAla*Two<;8|V|`aj~N z%%kBBZco?=^Hi93vgT8FxcMn;m>KgC3MLUidle=G`O)BZT;-Qs5gavUP4*ow5FjUz zwzkoCcyye}Z?Q@13yt+Ws5t1nM*fpm$t{^gl&(j|!O5KREhZhmjr?bGI<|y)xjsZ` zCE7s%=*CnR9Ao~~;xQV_3XMsQjjDo?F!7Z<042WT_pM`;fTP>MM2T_bb7gI&e^o{rVSH9MwhR3n-W^v|xR&UUWhzK7*X7&m(Vh>I;RyFgS30Tf{eL@`+-Q zQ93*t@eTaPSpj*&G27#rdT@?zO8Q%{p&bvI88OxV%k2siy4~2DVJzX_+BbOxg#W4K zo@lQBrkXQ_=m|ZWt8AX1j}HH8^e5?0^$gHR02i7R?!?-~YMBzT`0Z|Gmfs-!Ps;mm z9{snC7T`vdNCjY0K`F}SD$YEDI z9}yc##QHx!riv2@*ChYHZt`Ev5fyouVXkZh{2v<~#GMrHZ_}pvUwixSdI9e+0_pz$ zy@h}Cb2%mVv1144|N1PjjGO#W0l!2vpuHbadQl|!;Y3tyHOBmr4ejU0RDdapO+N$0E*H}ynSDG=jbs<~<7Oo3 z?UeeUtD&a@r{_u822R@eS|L-3usuuAer-3AF5oAkp>-!o8ndT}Ns){*n}G;Ay8Sq+ z>56Gl&OoE%7pte}O3Ws;nO#*wJ_u71Qw?ODo+Y)30IMRt==0R`BuE(|56wqz2aBtJ zM^zt(gtNtkMh4J2BLY8{Hq{cWBVXiUpGmjLGgS(pn!imj8RDHIE*@RdM$wu61ieAc zLA3S2ZZhX(y`0G44JlgxKEnA^$=*pCSJG`*?EkuDD?Z&^-?g939>$$&+JG0 z8y?#|vJkLQAOxtE00%qEq1`%^@K!(yFHH}4ygnoxIIUegb|)3Ke|4}Fl0vy<#`~q( z;KS8k^JR89gn}Bw77n!caH@AaHUAi@!|$@9EzLeAEidtooAPHPxek_?I{ejz@11F8 zoT{#_f9;Y72CTS0_K$2&`JQDPFj+#qn!^t{or$Jk&DrE5*S%#t6)^OB(~C+kw;;Ia z4qNnHyT5$+{O2t8+w}DuiTypTO;=OB<4r;ai<0oYWi|H{JONGn^wNx>&)!@OiF7ns zXBg`=JSb&2UE=+Fu7?fBOa-@l!{`SP5pTVjbzw(Z{dCXvT(vpnUHVVE230uFLlli& zso{QuEdt2sLqJZU+tWP*FPB4UsR_s!VJwFsO4OKdk6lH=*RtEUdxz)pKP}Md*HmX}3Q`+g8MMK0gaawJ zN3n}BvjqVO=~}bNObDbuZRsoO?Tz5F?}PO{6g#UX8{Is4eN_&7dqc!im2rWI`@r|8 zU3b0A)~pSMVoy}^!|RVjnNm`UObf4*DHs^hh(7HP8;1foAaQ<{ih>(B08jI`+1M7v znRc$`oXonulg-2K4`+Pq2GoQ%Fr!C8^e;x19LmfJWSF1;|Lp21b@r_;a&Rp z6H8r2fxZ8WP}Sl zl|8=fI2RyYhW7Y|{~UfGekkS2Gmb*w2`xfq^|_nDn5y2bY1JQ0nFJZyxwCt;W;0{P zUYNE4!GNhED3({21ayI0+gm$UPynx#ozDaTwXQ5N`yd@QpSn^7NH0&121QMsx;OWX8PSm}jSSk6!Bb>{buwyh+g5LE9v?5!UwnzctB zd}`e|deQ_3t&jbJ&|gN|Kh1s!V-1}P?diPkv8;o$|Z0Bnj5AwYP?CUpsZ zc)AE${R8Az?^xDzOW_4VhL}#6ou;JB@%=F}?OrnbW}uYZY2al{a{STT+A&IZe7OBq z?NN)Q_+>Blf}=*BK*R2G-GlT@{kr-5CbD#@~TVEBmx$gh7N+V6XH2-f*RIM~Bbwh-pJ zd@pPke$u195`#?uiZ-oApNJc!_tDQqzM%1ZMK0g@Mq6P-l|5A- z{>2~4@Is`54ih}>;E61Xo@lbq>>wQSH{GiU6dea=NgrO$r^yU~CwnRtys!u)I>l!M zF`+9ma#APdDqH50w~r6^Z}Z{Y9up5c=WXwqK`W`tSF!Gc@k;mbsZ)=12f9P<(Nf{| zzdX|woXDbsjO`WlkgY9K0*0nM790-=4Qu$At^emNz|bQMhrIhA~#ym z{;R=7KYn&jw^k5;54`}ED_{>v6Q5SwN(uKojN0F{wleEzu)Rk)XucgvI@PLe^&3p( zdbwiBPNNW%F&K1hnBD5uCx3eQ_FF<1*q5`$xo)?#aaEC=+*X;|&!6by7$s~jr3mk+ z2CCN&rkeF%%|%~BxJlX{2sz(X(Obs-CBEji*Ap$GFVaRKV|44Ip#7g_^G%iMGcM>TU*1f)M^@E_0NBvYZ4iMKw(JeF=HTXD$7zjr>-D+$ zW3m8D9Z+xhSDf6lcQLmqq1^&{ST)if5&fHX23NoDk{m5YaE5qaB)$pbZFODtK}1Lg z^V;Y08nwm#k=*aSpEv1;vwO$>W1)8kza=2bB2Tgm-&y6E31YG zdS2-7PBHRmXjnI?5!B7>yO5+QqBuB6wN1~46d4}d)+>;#H7odyayHsM6ja!aeoEu_ z#!Ugt*6(lO@4pLuh+?WGBsk5_*>qdukRX8{-Fw`E95i1FZKVVNNoyCQ|KR6w`(jL^yaPoyD{>`$jAeMi*@N3);DCmua|;aQ5xn{ zG+bYN_z;qROi(JSrB!k~w=_lSs>ibrE5_fAGe&#;S~mjqyE+b+I9hd&j%mE{j5V87 zbf46qeRgQMQC>j-gt3!vc}MY}r%%1MJ8k}PRCKE$yf1t#>6CZ&Lz0^UIdLj6tH(fH z(6EN*xcSWfF?%$ye^M7uZQiNOp8@^xq^{n^8+fSlZG|coZ-+TD1p^RJu)B1aWnUrs zlen*kMf5-O!d3V~31DTJH5%eMEnO@~TR$1`&7Xba!|l3ZTpWG91qz%+HSh$_bzOcn3R9)qBKWzERBkq8>+8ScKlD8Mi(YTZ!S~BcJ{* z;-2E5{U%aLf454h6E>~ySm%Km>IhM}9a$QMW6Yx_mQ>HClk4#G5XV})wJ+rN92!WK z5O|zlUR~u}Mg)1CGhD8ZtcF!o+n*}sOxZ`^DmE5TO?^jH=cug~3yz)oHRVFrezhAA z9w5RJHf~xJY4aFl@Y>AGDuB6yfB-ZyIf|*Sew0h$BfNPx=e&%}gNx~8Fnus>h`ITA z_uzV5_ISdpR<9_o?zoo0?3+m8FXEL4?AxbRxRlh}dQdsw_?lGh*;ZPQ4h1IisuN9j zfriTJ?%7LR%!{phg|2Vb!|R`Eec%$1v(_jWmajHqD^X{xrU@lrI?1FdXO#&obucY;SQdz&xnvh?Wbe!BhUK8vGAxato{qg` zPDNf>i$h{{zn^Yx8Li4!=G)obCD@rv$Z}UuI?pa?f)}aV4L)Zp$TNN0^gSCrcp5tV zF+;!@T|l?<*1aWlh-kdv6*VIQ*-zL?%VtU)>m$l~sVonnQ$8qV%@@R6R&JPI2qpV=mKqPc8V_4S zYafr1!8f*d%gScHPeb2l9yi7eJnHJWY5~d#`U}_o!2CPoZCODrEF=&O9#OPw3b08= z;jxc&G&vH1gbWuyX{nKuGt@g+fJ$%FrJ6S zVIBIG(;g%?-N7f2FW{)31KcEh3zzoeXOi{OTeC+WnM$mRerBiW;N0y6wDQwqDNX`J zp17uw2}s6G?`GXHfr9SmO@>QfA`&iv5Jf#tZSMnbuXiQyWq*m{uJ1Zdg~>+{apQ4L zZj{rywUy_j-X!vL}c1|-7=13SAi9I>!xiW{E1t3*ji1a zCGT3Yeo;QS3N6d<;oA(p{(9RQ1ek$4P0$-Pg}AG5blot3$NuCQsPneFt*zalsuvhJ zjI=t}#j~$kMpHB*gQZk7LXT6qd7m#oF1fCk^6D*vR1!P~*AH4T0`#dyJ0A9i9kevx z1*m4<$w;WHKPR?`)*nb371Zr)TZ?!BnyJ4X{`QvIZfMo+d)D4jd)>0`&HWe6+n zdyb4UI9OED4QAV?HHS4Ab8mdeV6-rKVxq6NH{q1eZsSaiB_Yo=>*0;kN~rLa?!x`@ z)h02Ic5nG?q~s96drIuzF0^%}hSz=bM-Re}%$qO;67ueY#m132<-m!7isnuK=i)W@ zPr)sGrd}rRt-kna` zXr=S6%kK*+L@%@p9H|+Qyp;4V@51HxvbEXeJGRYB31mHvOYiMsTtuSEPD77*{O_#V z%=q?eU1$POUZ3OB%4d z8T+r67hY519+B;{3YVN1^-sa^F!5+y53Te0cHEmHjQi%+PFle{)1$2lw@R_;88Vx? zxKP8vK%7s2{DI6WDWkRI0$)7SyPpmBj!#|z5DGCy{8lc6z@Mh2>XBuj@`%HG=*h~@ ze<9he`VuvuBAO9aE-#bgwGC(DtW?(1Bd16wq`9?b*YHkR)tlxZ@ucz{PyD+#9h^}6 zd`yzyN6%f~ik*w$^ABUN!zPr&rhC^slc-?2uviXV{d((#Iy}&)sVfA(%)2uf9fM$4 zd_mE``qgLEt8oTj5e0?4uCN*$ZvsBpkt;{fgz4LkT_zWP2^Fcnql&B6+6O{*)8WW3 z40xQJHJZ-1uyTV=Lz!MM)(4lf*AzyxaISJRT-I}7!r_Q*RTX77Mu7gP3;(MoCdKH9 zarh!actcE4YPa?;le+XzF!{$L;-_21$**B(L{D)cop>CrpozgJR|}dX$ftGax!c`m zTD!$G-Xv~U8~HTmmMi`VwM>7y`53NG@JVzj22>NBV6b>*WZcx$`-#a(F{~Q{rIWT) zA$)nNIXHb78F23!pE1oKBlX#4z#srb#ztF1L#&YT0MvxUG@*|*XW-5 zyFM<&uMn`IeG1sHoL6wAAtY6(8TZGJADgxfrR@hN0i50W%QE}}PBUrb0AnU*EQxf2 z5gxz7-V9Tbam)f{kF!1~l(#Lr?eQJ8d^LnS&sne_b&RVu;r=NtA08fsv}YY%$q z*@Ld5QAsn)l6D2|Mbz1hpxJ4iL>A$PXn4p9whf-{Ugu~;L1fMEg)+XzIFz82T;jGwh0 zNu3==w&L%JneMt5Zm#StrRwUikG%?emw?-edYNzBGx?l7 zN*`k4r(-e4!ZJ%j5S9OW%S_1hjmER*byi9N{O)dt1aAQD261F^Hb6g%AcdHN)`bNM z33HHd#wI8o{`x$0bkt+%ND&pjBfuJ4V}L#HHJnp*MkxMS=mB?bC}l5(tDK4LtXZ$J zl`j)5aPA?yB=lE6;}cCDl0lBF^l>=wguur-SxP;{c>(P}A+Kj+FpT}(jo77KTvO+o zfb9E^U_-E=5Je0DbIYB5-)L+Cru4hJSDoJNnnOXI2WK4z5z}3~Z+zAT^M!@TFu6ie zxI)j9*gFfO_3|a+$YjV(1YiCU+kQ(L!5TrF9LcWE$vTY@08qYrYlH6%XvHvzRtSsY zJCpR+?amjFC|aartd8=do9NP;cSs!ehc}*>0=4tA{`YoL5dsyr23h~tTmYC~Z0Bb9 z5Fwxjy&3XBFBS$a3OX+gU)CJqa(cn?0_U4i=qyq$Vq+HaJuV_1-~%dbEhHSAW=^+u zi+d-rRGx+Wv;q0Z+4OK#4DVC}0q!yYA{w`kOHD*Z_H)as7zG?SxEeskpGEIeD0im_ zmtzDp)FAy4PHHEtK&tsjB(tv|3E2=x?}$2ewN1K>6K8P4z*=7biOzR@DGj~1Rfy_X zBDi_Vu9^4*%rL$Q{X&v*ElqfK6P_Jy_7nME2>QxjL3O3ci*}2L#`35ep`+(e=fS$r z-J{$1_V&RuqQ&aCSS}ra{-;!Lz*hMs9=E@F-%y&|4-eK09<^sPETNcQZvjiH0K-#w z*BF`RRnny}ca~AqD0ZgSl z%f<6=R@hYo9Mt-MP$GI!;|2|;+ViF0+Ou%tNcjj`m=Y2{1~|hHa%_Lhi~53Z6pE2U zC$0{!{9G8ASEwXp(YMQ7vm)!L=RnQTvv-ZmEN~;SoVQMDBu;ommy*n}ZwA@ojQGI> z18gs-*RR7$VNf5ag_#K}cV_O^!J^&$gfmv0Rp|0Eny&^4*btYRpJzJj2YN?UZ>Kn3 zTO?nX*!g?h?=pg8YLGk?T;sxU3Xik7PuUHKL*j;5hBZG#g#oO9f{96zl7&Zyzv3T> zs^8%v=JGGf5U`)h9lMID2Lg7l1nmAR`J8f0mnAIDY9d%U{WH_ymW$*wV-`^n)%Dq= z6SlHMvWkuGPh?T9Ag=N6i@ZWpHohnj2Q^5PZB9b{SRBnMc|R2rwpm4VD$qd}`fc-u zM=%0yQ+EoAPw@)Cpp^!q_dKo15HTzlQM9Xpmo$r^KH8{(=l7hN;3AKkGK?9odQ5C! zWMm+yV5%g7yM9SK$%*v3vnQwd2iHUl5%W9Ft$>}+e7&Zn);dCBh=(j-aMN)ek`AoIz5FgQF2qg_r8g&`--Cexlc2jm!p>4q=ar zfCzx=$Er&GA#z(5wo;z`vq3j?rJ|~VF;opZrraff(b5y^wtA!xMhFAz456qP(KdU4XOwsnpQU} zvS>0AyS8zx17h>2W_I;(2fof`3X9!Z-Vc}|feA+D?2rTKh|Ys{fv5x$M4gQt^@_Nb zDwdNvYv=f67Hd8mBZ)ljsMiAr$mUxxEholLtjQQ_Y(&0P;K&Fjz;mWRmGcz4T7Gx7 zx{o`K%zmW!v966nq=0Q^(Keu!x`;%*g+M@+n_*d`a-nifG-Rlb)iJ#(T0TEzr#&5$ z;jA!#5?9uY*YXQ_o#;=Y)|adYrYa@-yGxbz|bYUN2Af?8%DogBG{_X&Etc zjKs5w5v;K$Hyx)O4iM{9K8USD;6xL$U;99e(kv`+R~AadbF8H0pkTzibRgYEjVAq( zeaeG~vLS#GAaWrp;4|@O)GVyJS|iKYDlUF-QtrVgwA$a&t}k^pMxew?vN{m(IDq`=NYqywZT)`wg(Q@su+#pn~yv{rueb zRuV86YW7vY12#bKhn%z(4yWyAn|59O9_Ivdo)h3@!A`{dP!{NbQw{fI$_DMu{ObU|u$uFI=Z3@TAonuI@Z&}IG7usFEfLgo*OBB2R4WzkrvyheoMIR^ za6@=!uCKVuK*pgs5aw1~xi%EhIAxbB5V@CK&9NlK*?J`RGE1lXX(V^nYbZ9x=W3#* zASTt;`FK+FR#d^Kb+MQhysQmUAN`DaIP zcN@&UPnOC@rd-{jcQ}n;JMvH+;OUpcA<|9NhtTUR$V*=a!nv*ZqpS_VHVENYSg*;C zYS!CPG}d!*E(2H%9mLKAf!a&6$>{Z5s>SG>W-xXC`>dvtiHY+O@m;`4qxCgB^RO+5 zKkf`e`1w(QYhyi*Hd6t>^|HoNMtGv~D#yg>_`N`mo4V1ZQ8b{1H)Z?twUk?zFI%%% zq}X8s1`S9mVp`%@+DsZ$OJm}iRhtHg_vuM)gH)${)PO%+Hr+`S{XupFyzB%lZ){;823%>hA+Eh22s=zeU9HoeCaz623Mul>j* z_CpW$i0~7(s*H`zjUMxH=SfUTZCw*yRQ$Qr;g0=_u7pQhU(0GvU?w>-r5U-qIS@JV zy%XiAw)GxME(_sd=mnyeb^b+VC(2W0?6t3uZQ9{BrBUXC+Fr_~&24I@oAU|P*@KH zvchRkAGLcP`k}!e)F1Y{S>4kNq_JWZYm`OJ-a4I&?lfe& zO%w3Wfr1i=$L(S1dLl0GU!Z@XS%;>=C~0X);vG)?=m=dz4JzEtir_`#+Uv1XJ0pjN zut9A>XzQ`Oulk#$ZK*AhYPhB_56z&?nQO@;KuR(|fQ-79%Bkbe0&smU;m=SG5c zs;bsxP@MG`)K=zm&QPN1jB;^si|eOi!|;9)4qF71alrGG5krCTx$$?_OWWmNSZTYg z>}j2P$(|QJVH*s#JxkscYsU(^a8UhP-lMDh^O*`uZeWE7{4V=Y!ox({}Xr(5iD+x)!+@UV%T)uoBjg4?Org5z=`9Ed@q zlx5hJSxZNCkZ-siTb;9kw)JANEUO{^1;1-EvXX;E;oC+1?Ku1hV)msseRlPs?whmL zCc4dcV~>!nL%)3Fm-FeskZBU=OsnmLthi82hLVs$Nt~WsGzxuKw3u;5ZrM4Pu2BQk zlfXntKf>T1I{3S{H^it)9P6gSVdEs|8n4v3nBt?Uh3EZnMgOgQGN0g%J2w2v)k?GL zlLi3YMVnh<;`|6=92STK97e)m)QEin?*p%LppcU@7bSm>=1o4ZU>vXYUFCpS?=P2o z_qcjZhcwF_51`qBO8X2{L=Y#C7l%*AFjp@U&^@% zw3rJPSy}*08M*d7F2E7R>L~|3*$q%GB#bSJLNMUzJN9841du?Zaq6*vgUvU|OTG#3 z!)Kx~F<;XORF~^Z*HUo=^r7y<-g;2rb1N5Az%Ehl(#3mLcoEm__oET+pJ8v;H+j5L zd#{#NSqTq#3$6s3O*AXRDXo%Fuy*;7?~Iy{fmmO2kvO3j*V`HJ8A$fn`ArhY`TPufqI$MIHXiV6HXh6ac!2BtEp*MfV_Q~SQj$n_ z-nwZ4o0KOE0F;*!`*JGpDnXXh-Xy>mt-)MXr4)pl8OPn--Oh6%+cUSHuH&0&=E3Pw z!R4YSw^8c&9XG%?sEcoBBV27!c3Pg!9V`}>l=!tFR_*1>Cx6;>bOpR5Bp|0(W}?RK zXys)BnNV2SeXB3KgY0y<*Y!`3pR;9a@JVH-X5$n~0%77CbRt_RJ_Mcp-~Ii-Ll3vp z6e5;yDP5Xw*k}||f?Ss#8hI})CyTy<{Ae@pUISw=lPDELKb^)$Oi&CJ|3MRQKxM&^ znQ9<$%cHB_h8S!4I{GlX=?wRmwfhUC;O-S|?#NGp63(+cw5YM(DnfjAZFij7zhdu< zULHop+5ogF)oe&Id;aQjD{ziNAGp!x7_-4I+xdXJJSwVBz=(L}c&Gm@7^LrC%UH3LIK_Bp#DIgo#l9mb#{P#$C9krI3z*-P$i2>S+9n~9j0;-Z2X$O(_GXDQnrI~BcQu&Wo4q<4 z`cG=6D9ocAJ0Bf{`61n_H3lSvk&8S6e>um5w3cMc9l6{vKoo zO>_SF1AZ$(%I`7&ZW>D3Ui=imIzs~Dvi%qhcq6O#oLY&dJHL}cppmOo2ab;EUGLyc zZ=~PRuupc7QP$KjXQZFSs7+)EzE0#-x8WMvwYKw&GOKu^nC# z-(%qPS&I2}9Pr~10&zNXU}oJ(p?4#w>$81%1w651gnfifvAWA8{6GcLKi`=gtxa|B zcc&`Tb$3Pq0H(rv{#z2A;ExabVkIc;>7U-bBWt+@@&e`cf;HQ4M)U2_Y3BX2cv`(L zJYWFSqb{&jm8767r-xjP3~LHl`)qiMxuupSd~+YQUdpziGoa+hb!3n6fV5c(!N4 zNf42QJQ*NTPR|hu%4~OBu8$edVs_1j2cI`n>?*RJF0TPk!5AI3;N_fu^eUtkv`Q zddA_1c$Jfzn}mWXqT8)zb1)SJw6(Y8M>VVRLB$_H3OBd?+6V(`d7zs3a@>KzyhdSr zj{u5EC;Py+87S!alt}mwIesO0?(War2X{&&CJvp;xNq}G$adUaV;mQxH?zi4Hem$ZCUrlRwO7$^&#rqf zi?TOrgbHtcc6UigLIakl=Yz!Xej!}R_lBnFu^j~zv4l*6I`hl=Z3j;v+;Us1;})0$ z1vs5K7fttsV6yQv!NeH+QRF`mLGo!l?W8zP%gwGN)?dlD(VKQNm_MDT)PVes*Lx5^ zK_i-U{%F}1DnQXgkQLm}KES0k&EhZtuCA_L$tMvGCb4Zn0+qYG)p~!K{s+2<%TA~W$KqJVmNrj|=`Sk`y%F&TXAB1VG}DYl zi;(gCoVsOh8@GWYXjhP}cCG87E^u}u@u>Uu;PdoiWJn0|!gX*XAoEOjj8qQ=9leb6 zywGBAV7Bpq4by^sVM~h_W!kxJ(FPPE>V0tM4)UAdm&z($Ofn{WC2)bBmKwMRr+=2j z3e*pP7nr!HJK8x$tS9uwS9qKUg8a(7&mX|vk5{)^Gu6keptg!!=~w0vuNuf%p(Ars z=xv3yaw90B2}ehBws54VH<3)6B_(gnKJFp!rdnXDbI|riE}?PU&wtQR*SlK)@#!hrj_sVck}|D$_v;F&-2cA6qC6&b?|V z-5kh9ev`+c>vt$H$y`k~tzDBbMgr;2#&u_Vq?>8L3QI7)#=hZ)u)ytdTR|(SzbM#R zDJVGOa1;AF2<9-R9BhnCne6ol*smcPZqggF>UIKIo)EO+P(N@32hxW|+?9}a&NOa} zbFben-;#rX9;wA(X&5AMd557{>w*PjZ$iVu%e=SGsH>XbTU`7QfJeoEH^@#-FpdVk zSpy-6RXdNNGYyer10G332hG$t5>oYIQ;&SU3wV{rV-H_n@1B2PD|DscIHs`H#J;s8 z#3EtC>$ZjajqyVSkk?W-ip+_f6eLAO@q})+a_e|UCT1YQHW=auI9wMg#BT4H1Z~x9t0te}!No1%WwX`Z6VZ|W79&TF}lSda~eg=Rs z8gZZvaXq}*75)q~L~ty>gbgEB^HXg*e4DS}(aX|5`CM~NaCdFd)1^cJL+Gq5Gd2m8 z5aDVBWEg3jRcGk!W$N_Q)YQs7&MPTB<3jstGt)>_frmWSQ?`qiEiZ{P!G){V89U81 zTE>*usu51X<1g-m$r%vcE*EPl7iXJ#j6nK@KiHb^?6=n!4}eGWnLero0JR4la6jM| zJ|x|$Q|m{$?kV=>1V5ERz=2L*j%O@*zE_=ZL4F!~?nI7dkBAw*KK!7S#MV1%BhR>G z#m4c-69>bl)m-5lxXpoPasnE~u88gNmD6j`P=&=LJ*e#=8r#ni&=bv2oA>U|S_mq< z&*|P&5V8M^2UQrpMR75JNP&Qw+L{2pD5P?&f4N*lpg}DxDuM@DEw>;6Wyw`HGp4PE zv9aU;C{&XA%iwYH==xT^JX6$XrDVw%2*p)2|-#qwNnWiYf34pUF@0HH+?$abiV)I z=lR|9JNMrAzUQ8E&v`GV?3kgbnupn8Y!Mldg<9AQm8P?ak^|n?Ii90 zlEbc^$~@;74GU*xcYg2R19;*pF$+MwB=TUtM|UZvmZ;X(NJWX*Q&F);m73hr=j*7j zLU2?=q z$(r$Xr!z&jx4Z9G)v*fLwZk{XfnBdM(8R>-4t&d5kV7Acdw1MZkQWL%69TekUUPt) z`Ed8Pag~@|P2iwHtX4vTag0O0I>`0diDOQreMV5|S`t;|&N}#6bS*-CTKEJ>FlKJoyH6Y_qc39* z%?6*n3!D&ga9Jr+2n{otoS~mzGTK|PV5evA>-;nvRi`TJU3g&i?&qHj6F~{4BJ|#h zCZGWQbTy|ic|Du3@<~An*-40r{ZPgK$kHCerCG$?i(rb2C}#NubMJd~C>HFhmZV~5 zW>_k$=6f>?ZU5=?VyD_hbZyU^Vo7_D z%t~y!o`Li6%nG6ef;EyhEOwUJxU_#9@GkDF-YXR?>Yo3(qCiy5y}MNbw-*)0 z0K%WwbPGL@a!imn_0SAJwD!P>yrC;0O4GQBIK0nbf4=~md!2`L1GON2)w;{6k_X7( zYAnpcm>AxODklcZZ;6JXYk$^0z~jf7m@B7kA9%esAJD!$b;kF>g;W#=Xy8IJe-Q8e zvu_bDKPWD?`!Ck>9O2+uwLHNyKW%C)!&!dbE*|(P^fg_=Zz9b#n0a|+3wYetp4>{F;L#pscB=)p{W7>Y*(Aer+Vdo4$!}4Bg#%ZnGM0)7&W6WYfGa z;pTOO9fBi(5B9s0CZ_vOdMnG47pUdaK(-$a7JmqOS2mPdC@%@W8~yMtqj}(&n=G*K|vSiYabz4Uh2k!nPd-?&SEo_M%)&x7U@A2 z)mc$eq%Cl)DdSMqKJ#gMly}8GxNeD7)8uA4g~-Lmr>uoV8^J|n#OiL3wY5!eNn92< zt5iWTR1S@CB4Q+k2Y)?7NEoR^TKHJwITyw@V?h z4KI9}MX-`7ZDFUTD)ri3>1^)B7+>0cURF51koWe)%Y=>;(z%I{>X-rt;!1n(${%t# z+C%s7mA2F;25YN(7tYTP8RNrO?A7cQ3enrEXDO6+e(uM5>!~9Q!u|&9n6UvEsg>xY z$GWqPlf6RHK`pP|!^`cSOC54t@F2kk~Bk;O!m)>w$U3^%uZO&6tO|mv{ zxsXtPO{}|z=#z<-p3Q59txt(nI(7w=Iq54%Lwy{HM9&|Bag)Z+!onY=q|WL)dna9$ zT-1oP4%Vnt;qp4(#)fu)j%D2N@ztv)E1R}f)b!al#ElOc2WJ_|*M}V&M-Ov5$G*F8 z<>4kD%H1omEGc%I25BVu5D1ao8@;J0-gN8d8V#4z-n8FgpWF#@D^9AaYiuocc1U2n z95~gsNl^0jQ8zB2+`K5fo_b11SeR%>{+x2lr&Rw8x9k-kNp;^GlV)p5MP0umG2(y_ zWT+423Z5f2u1e=SN8rZ?KS~+~A7rL=w6Z%h<%8ApU7)6*(K0DD`2p?P05*pH@*YIuHPkhn-teDkr6{$+>+Bvk8HUq{WxWp8r;sCCKJ z)wMH_Z}O;cLaKUFm7=EMDFqJdqY80kecN`_*kbubeV5867X;LjQs~YUkJ&eW)yrV# zFPz-&*2B71DVXHv?3n5gLj+Soc@`CR( zlW2WEGS{_QRdluYlCJLi%Y$H39nb2Mc@7gX`EMV*zz#R%1U0u@npv|{^Q5**nWtHv zQ(}uFOK~+-ylwdy!M{hd3k8+i7zhjW;WnS~bv0MM_^$Br>Vf-Go+d)9%;;Ut(Ks2% zELZ#RRy+d*d^0icAv}?Il?me@tfW2mb);0Guxi>&c&L(;Kx`b@%3)yCs42s*?o6pC zw8IvQ#dFS%7?<7LaX-!9;&;>Wb(C5ODo@@nooukp@>dLfKie}Ml*N9ZPY2#!3{%!hEY z5YX{-T`GC&J$g5s2EU;X&Gx!Si*gq-x3C)N`EETmyT>DtJ)5B>9w=E@a-~3Qwvm{e z`v>N_klb^<&y_5MDJ%V!lY1Av)Fcf|IW!iZ;vh;U9S|9?!1q zTtA9&lU*xDD`+n+{D?50lQDpb?!4(Uj)AMLr{<;b0qBOmRYqX*vB|EB-$HXTYIzpF zz# +#include #endif /* audio "exact" samplerate, measured on real hardware */ @@ -48,6 +63,7 @@ u32 Shutdown = 0; u32 ConfigRequested = 1; +u32 frameticker; #ifdef HW_RVL /**************************************************************************** @@ -65,7 +81,16 @@ static void PowerOff_cb(void) ***************************************************************************/ static void Reset_cb(void) { - gen_reset(0); + if (system_hw & SYSTEM_MD) + { + /* SOFT-RESET */ + gen_reset(0); + } + else if (system_hw == SYSTEM_SMS) + { + /* assert RESET input */ + io_reg[0x0D] &= ~IO_RESET_HI; + } } /*************************************************************************** @@ -97,31 +122,15 @@ static void init_machine(void) { /* allocate cart.rom here (10 MBytes) */ cart.rom = memalign(32, MAXROMSIZE); - if (!cart.rom) - { - FONT_writeCenter("Failed to allocate ROM buffer... Rebooting",18,0,640,200,(GXColor)WHITE); - gxSetScreen(); - sleep(2); - gx_audio_Shutdown(); - gx_video_Shutdown(); -#ifdef HW_RVL - DI_Close(); - SYS_ResetSystem(SYS_RESTART,0,0); -#else - SYS_ResetSystem(SYS_HOTRESET,0,0); -#endif - } /* BIOS support */ load_bios(); /* allocate global work bitmap */ - memset (&bitmap, 0, sizeof (bitmap)); + memset(&bitmap, 0, sizeof (bitmap)); bitmap.width = 720; bitmap.height = 576; - bitmap.depth = 16; - bitmap.granularity = 2; - bitmap.pitch = bitmap.width * bitmap.granularity; + bitmap.pitch = bitmap.width * 2; bitmap.viewport.w = 256; bitmap.viewport.h = 224; bitmap.viewport.x = 0; @@ -129,6 +138,63 @@ static void init_machine(void) bitmap.data = texturemem; } +/******************************************* + Restart emulation when loading a new game +********************************************/ +static void reload(void) +{ + /* Cartridge Hot Swap (make sure system has already been inited once) */ + if (config.hot_swap && snd.enabled) + { + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) + { + md_cart_init(); + md_cart_reset(1); + } + else + { + sms_cart_init(); + sms_cart_reset(); + } + } + else + { + /* Initialize audio emulation */ + /* To prevent any sound skipping, sound chips must run at the exact same speed as the rest of emulation (see sound.c) */ + /* When TV output mode matches emulated video mode, we use video hardware interrupt (VSYNC) and exact framerates for perfect synchronization */ + /* In 60Hz TV modes, Wii & GC framerates have been measured to be 59.94 (interlaced or progressive) and ~59.825 fps (non-interlaced) */ + /* In 50Hz TV modes, Wii & GC framerates have been measured to be 50.00 (interlaced) and ~50.845 fps (non-interlaced) */ + /* When modes does not match, emulation is synchronized with audio hardware interrupt (DMA) and we use default framerates (50Hz for PAL, 60Hz for NTSC). */ + if (vdp_pal) + { + audio_init(SAMPLERATE_48KHZ, (config.tv_mode == 0) ? 50.0 : (config.render ? 50.00 : (1000000.0/19968.0))); + } + else + { + audio_init(SAMPLERATE_48KHZ, (config.tv_mode == 1) ? 60.0 : (config.render ? 59.94 : (1000000.0/16715.0))); + } + + /* Switch virtual system on */ + system_init(); + system_reset(); + } + + /* Auto-Load SRAM file */ + if (config.s_auto & 1) + { + slot_autoload(0,config.s_device); + } + + /* Auto-Load State file */ + if (config.s_auto & 2) + { + slot_autoload(config.s_default,config.s_device); + } + + /* Load Cheat file */ + CheatLoad(); +} + static void run_emulation(void) { /* main emulation loop */ @@ -142,8 +208,12 @@ static void run_emulation(void) gx_video_Stop(); /* show menu */ - menu_execute(); ConfigRequested = 0; + if (menu_execute()) + { + /* new ROM has been loaded */ + reload(); + } /* start video & audio */ gx_video_Start(); @@ -151,7 +221,7 @@ static void run_emulation(void) frameticker = 1; } - /* automatic frame skipping */ + /* automatic frame skipping (only necessary for Virtua Racing in Gamecube mode) */ if (frameticker > 1) { /* skip frame */ @@ -200,77 +270,6 @@ static void run_emulation(void) } } -/************************************************** - Load a new rom and performs some initialization -***************************************************/ -void reloadrom (int size, char *name) -{ - /* hot-swap previous & current cartridge */ - bool hotswap = config.hot_swap && cart.romsize; - - /* ROM size */ - cart.romsize = size; - - /* load ROM file */ - load_rom(name); - - /* ROM filename without extension*/ - sprintf(rom_filename,"%s",name); - int i = strlen(rom_filename) - 1; - while ((i > 0) && (rom_filename[i] != '.')) i--; - if (i > 0) rom_filename[i] = 0; - - if (hotswap) - { - if (system_hw == SYSTEM_PBC) - { - sms_cart_init(); - sms_cart_reset(); - } - else - { - md_cart_init(); - md_cart_reset(1); - } - } - else - { - /* Initialize audio emulation */ - /* To prevent any sound skipping, sound chips must run at the exact same speed as the rest of emulation (see sound.c) */ - /* When TV output mode matches emulated video mode, we use video hardware interrupt (VSYNC) and exact framerates for perfect synchronization */ - /* In 60Hz TV modes, Wii & GC framerates have been measured to be 59.94 (interlaced or progressive) and ~59.825 fps (non-interlaced) */ - /* In 50Hz TV modes, Wii & GC framerates have been measured to be 50.00 (interlaced) and ~50.845 fps (non-interlaced) */ - /* When modes does not match, emulation is synchronized with audio hardware interrupt (DMA) and we use default framerates (50Hz for PAL, 60Hz for NTSC). */ - if (vdp_pal) - { - audio_init(SAMPLERATE_48KHZ, (config.tv_mode == 0) ? 50.0 : (config.render ? 50.00 : (1000000.0/19968.0))); - } - else - { - audio_init(SAMPLERATE_48KHZ, (config.tv_mode == 1) ? 60.0 : (config.render ? 59.94 : (1000000.0/16715.0))); - } - - /* system power ON */ - system_init (); - system_reset (); - } - - /* load Cheats */ - CheatLoad(); - - /* load SRAM */ - if (config.s_auto & 1) - { - slot_autoload(0,config.s_device); - } - - /* load State */ - if (config.s_auto & 2) - { - slot_autoload(config.s_default,config.s_device); - } -} - /************************************************** Shutdown everything properly ***************************************************/ @@ -300,13 +299,12 @@ void shutdown(void) * M A I N * ***************************************************************************/ -u32 frameticker = 0; - int main (int argc, char *argv[]) { - char pathname[MAXPATHLEN]; - #ifdef HW_RVL + /* enable 64-byte fetch mode for L2 cache */ + L2Enhance(); + /* initialize DI interface */ DI_UseCache(0); DI_Init(); @@ -317,7 +315,7 @@ int main (int argc, char *argv[]) #ifdef HW_DOL /* initialize DVD interface */ - DVD_Init (); + DVD_Init(); #endif /* initialize input engine */ @@ -338,27 +336,76 @@ int main (int argc, char *argv[]) if (fatMounted) { /* base directory */ + char pathname[MAXPATHLEN]; sprintf (pathname, DEFAULT_PATH); - DIR_ITER *dir = diropen(pathname); - if (dir) dirclose(dir); + DIR *dir = opendir(pathname); + if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); - /* default SRAM & Savestate files directory */ + /* default SRAM & Savestate files directories */ sprintf (pathname, "%s/saves",DEFAULT_PATH); - dir = diropen(pathname); - if (dir) dirclose(dir); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/saves/md",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/saves/ms",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/saves/gg",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/saves/sg",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); - /* default Snapshot files directory */ + /* default Snapshot files directories */ sprintf (pathname, "%s/snaps",DEFAULT_PATH); - dir = diropen(pathname); - if (dir) dirclose(dir); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/snaps/md",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/snaps/ms",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/snaps/gg",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/snaps/sg",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); - /* default Cheat files directory */ + /* default Cheat files directories */ sprintf (pathname, "%s/cheats",DEFAULT_PATH); - dir = diropen(pathname); - if (dir) dirclose(dir); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/cheats/md",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/cheats/ms",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/cheats/gg",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); + else mkdir(pathname,S_IRWXU); + sprintf (pathname, "%s/cheats/sg",DEFAULT_PATH); + dir = opendir(pathname); + if (dir) closedir(dir); else mkdir(pathname,S_IRWXU); } @@ -371,27 +418,15 @@ int main (int argc, char *argv[]) history_default(); init_machine(); - /* run any injected rom */ - if (cart.romsize) - { - int size = cart.romsize; - cart.romsize = 0; - ARAMFetch((char *)cart.rom, (void *)0x8000, size); - reloadrom(size,"INJECT.bin"); - ConfigRequested = 0; - gx_video_Start(); - gx_audio_Start(); - frameticker = 1; - } - else if (config.autoload) + /* auto-load last ROM file */ + if (config.autoload) { SILENT = 1; if (OpenDirectory(TYPE_RECENT)) { - int size = LoadFile(cart.rom,0,pathname); - if (size) + if (LoadFile(0)) { - reloadrom(size,pathname); + reload(); gx_video_Start(); gx_audio_Start(); frameticker = 1; diff --git a/source/gx/osd.h b/source/gx/osd.h index f0913ff..cd549ba 100644 --- a/source/gx/osd.h +++ b/source/gx/osd.h @@ -9,7 +9,7 @@ #include #include #include - +#include #include #include @@ -22,6 +22,7 @@ #include "gx_audio.h" #include "gx_video.h" #include "config.h" +#include "fileio.h" #define DEFAULT_PATH "/genplus" #define GG_ROM "/genplus/ggenie.bin" @@ -31,20 +32,18 @@ #define SK_UPMEM "/genplus/sk2chip.bin" #ifdef HW_RVL -#define VERSION "Genesis Plus GX 1.5.0 (WII)" +#define VERSION "Genesis Plus GX 1.6.0 (WII)" #else -#define VERSION "Genesis Plus GX 1.5.0 (GCN)" +#define VERSION "Genesis Plus GX 1.6.0 (GCN)" #endif #define osd_input_Update() gx_input_UpdateEmu() /* globals */ extern void error(char *format, ...); -extern void ClearGGCodes(); -extern void GetGGEntries(); -extern void legal(); -extern void reloadrom (int size, char *name); -extern void shutdown(); +extern void legal(void); +extern void reloadrom (char *name); +extern void shutdown(void); extern u32 frameticker; extern u32 Shutdown; extern u32 ConfigRequested; diff --git a/source/gx/utils/oggplayer.h b/source/gx/utils/oggplayer.h index c0ddc96..85b95c6 100644 --- a/source/gx/utils/oggplayer.h +++ b/source/gx/utils/oggplayer.h @@ -2,6 +2,9 @@ Copyright (c) 2008 Francisco Muņoz 'Hermes' All rights reserved. + Proper (standard) vorbis usage by Tantric, 2009 + Threading modifications/corrections by Tantric, 2009 + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/source/gx/utils/vi_encoder.c b/source/gx/utils/vi_encoder.c index bf2fbab..402fa79 100644 --- a/source/gx/utils/vi_encoder.c +++ b/source/gx/utils/vi_encoder.c @@ -3,24 +3,40 @@ * * Wii Audio/Video Encoder support * - * Copyright (C) 2009 Hector Martin (marcan) - * Additional code by Eke-Eke + * Copyright (C) 2009 Eke-Eke, with some code from libogc (C) Hector Martin + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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. + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - * 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 + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. * - ***************************************************************************/ + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + #ifdef HW_RVL #include diff --git a/source/gx/utils/vi_encoder.h b/source/gx/utils/vi_encoder.h index 7a717ed..f5290dc 100644 --- a/source/gx/utils/vi_encoder.h +++ b/source/gx/utils/vi_encoder.h @@ -2,25 +2,40 @@ * vi_encoder.c * * Wii Audio/Video Encoder support + * + * Copyright (C) 2009 Eke-Eke, with some code from libogc (C) Hector Martin + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * Copyright (C) 2009 Hector Martin (marcan) - * Additional code by Eke-Eke + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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. + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. * - * 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. + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. * - * 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 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * - ***************************************************************************/ + ****************************************************************************************/ #ifdef HW_RVL typedef enum diff --git a/source/hvc.h b/source/hvc.h index 8a8dba1..75684a3 100644 --- a/source/hvc.h +++ b/source/hvc.h @@ -3,21 +3,37 @@ * HV Counters * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/activator.c b/source/input_hw/activator.c index 0ca2206..e741215 100644 --- a/source/input_hw/activator.c +++ b/source/input_hw/activator.c @@ -2,21 +2,37 @@ * Genesis Plus * Sega Activator support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/activator.h b/source/input_hw/activator.h index f372439..ee75b2b 100644 --- a/source/input_hw/activator.h +++ b/source/input_hw/activator.h @@ -2,21 +2,37 @@ * Genesis Plus * Sega Activator support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/gamepad.c b/source/input_hw/gamepad.c index 39a4ad9..20eae8a 100644 --- a/source/input_hw/gamepad.c +++ b/source/input_hw/gamepad.c @@ -1,23 +1,39 @@ /*************************************************************************************** * Genesis Plus - * 3-Buttons & 6-Buttons pad support (incl. 4-WayPlay & J-Cart handlers) + * 3-Buttons & 6-Buttons pad support + * Support for J-CART & 4-Way Play adapters * - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -64,7 +80,7 @@ static inline unsigned char gamepad_read(int port) unsigned int val = input.pad[port]; /* get current step (TH state) */ - unsigned int step = (gamepad[port].Counter & 6) | ((data >> 6) & 1); + unsigned int step = gamepad[port].Counter | ((data >> 6) & 1); switch (step) { @@ -133,10 +149,10 @@ static inline void gamepad_write(int port, unsigned char data, unsigned char mas if (input.dev[port] == DEVICE_PAD6B) { - /* check TH transitions */ - if ((gamepad[port].State ^ data) & 0x40) + /* TH=0 to TH=1 transition */ + if (!(gamepad[port].State & 0x40) && (data & 0x40)) { - gamepad[port].Counter++; + gamepad[port].Counter = (gamepad[port].Counter + 2) & 6; gamepad[port].Timeout = 0; } } diff --git a/source/input_hw/gamepad.h b/source/input_hw/gamepad.h index 3171fe0..5100e01 100644 --- a/source/input_hw/gamepad.h +++ b/source/input_hw/gamepad.h @@ -1,23 +1,39 @@ /*************************************************************************************** * Genesis Plus - * 3-Buttons & 6-Buttons pad support (incl. 4-WayPlay & J-Cart handlers) + * 3-Buttons & 6-Buttons pad support + * Support for J-CART & 4-Way Play adapters * - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/input.c b/source/input_hw/input.c index 2134eef..ac8d206 100644 --- a/source/input_hw/input.c +++ b/source/input_hw/input.c @@ -3,21 +3,37 @@ * Input peripherals support * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -30,6 +46,7 @@ #include "teamplayer.h" #include "paddle.h" #include "sportspad.h" +#include "terebi_oekaki.h" t_input input; int old_system[2] = {-1,-1}; @@ -46,10 +63,17 @@ void input_init(void) input.pad[i] = 0; } - /* PICO tablet & pen */ + /* PICO tablet */ if (system_hw == SYSTEM_PICO) { - input.dev[0] = DEVICE_TABLET; + input.dev[0] = DEVICE_PICO; + return; + } + + /* Terebi Oekaki tablet */ + if (cart.special & HW_TEREBI_OEKAKI) + { + input.dev[0] = DEVICE_TEREBI; return; } @@ -57,7 +81,6 @@ void input_init(void) { case SYSTEM_MS_GAMEPAD: { - if (player == MAX_INPUTS) return; input.dev[0] = DEVICE_PAD2B; player++; break; @@ -65,7 +88,6 @@ void input_init(void) case SYSTEM_MD_GAMEPAD: { - if (player == MAX_INPUTS) return; input.dev[0] = config.input[player].padtype; player++; break; @@ -73,7 +95,6 @@ void input_init(void) case SYSTEM_MOUSE: { - if (player == MAX_INPUTS) return; input.dev[0] = DEVICE_MOUSE; player++; break; @@ -81,7 +102,6 @@ void input_init(void) case SYSTEM_ACTIVATOR: { - if (player == MAX_INPUTS) return; input.dev[0] = DEVICE_ACTIVATOR; player++; break; @@ -89,7 +109,6 @@ void input_init(void) case SYSTEM_XE_A1P: { - if (player == MAX_INPUTS) return; input.dev[0] = DEVICE_XE_A1P; player++; break; @@ -99,9 +118,11 @@ void input_init(void) { for (i=0; i< 4; i++) { - if (player == MAX_INPUTS) return; - input.dev[i] = config.input[player].padtype; - player++; + if (player < MAX_INPUTS) + { + input.dev[i] = config.input[player].padtype; + player++; + } } break; } @@ -110,9 +131,11 @@ void input_init(void) { for (i=0; i<4; i++) { - if (player == MAX_INPUTS) return; - input.dev[i] = config.input[player].padtype; - player++; + if (player < MAX_INPUTS) + { + input.dev[i] = config.input[player].padtype; + player++; + } } teamplayer_init(0); break; @@ -120,7 +143,6 @@ void input_init(void) case SYSTEM_LIGHTPHASER: { - if (player == MAX_INPUTS) return; input.dev[0] = DEVICE_LIGHTGUN; player++; break; @@ -128,7 +150,6 @@ void input_init(void) case SYSTEM_PADDLE: { - if (player == MAX_INPUTS) return; input.dev[0] = DEVICE_PADDLE; player++; break; @@ -136,18 +157,21 @@ void input_init(void) case SYSTEM_SPORTSPAD: { - if (player == MAX_INPUTS) return; input.dev[0] = DEVICE_SPORTSPAD; player++; break; } } + if (player == MAX_INPUTS) + { + return; + } + switch (input.system[1]) { case SYSTEM_MS_GAMEPAD: { - if (player == MAX_INPUTS) return; input.dev[4] = DEVICE_PAD2B; player++; break; @@ -155,7 +179,6 @@ void input_init(void) case SYSTEM_MD_GAMEPAD: { - if (player == MAX_INPUTS) return; input.dev[4] = config.input[player].padtype; player++; break; @@ -163,7 +186,6 @@ void input_init(void) case SYSTEM_MOUSE: { - if (player == MAX_INPUTS) return; input.dev[4] = DEVICE_MOUSE; player++; break; @@ -171,7 +193,6 @@ void input_init(void) case SYSTEM_ACTIVATOR: { - if (player == MAX_INPUTS) return; input.dev[4] = DEVICE_ACTIVATOR; player++; break; @@ -179,7 +200,6 @@ void input_init(void) case SYSTEM_MENACER: { - if (player == MAX_INPUTS) return; input.dev[4] = DEVICE_LIGHTGUN; player++; break; @@ -189,9 +209,11 @@ void input_init(void) { for (i=4; i<6; i++) { - if (player == MAX_INPUTS) return; - input.dev[i] = DEVICE_LIGHTGUN; - player++; + if (player < MAX_INPUTS) + { + input.dev[i] = DEVICE_LIGHTGUN; + player++; + } } break; } @@ -200,9 +222,11 @@ void input_init(void) { for (i=4; i<8; i++) { - if (player == MAX_INPUTS) return; - input.dev[i] = config.input[player].padtype; - player++; + if (player < MAX_INPUTS) + { + input.dev[i] = config.input[player].padtype; + player++; + } } teamplayer_init(1); break; @@ -210,7 +234,6 @@ void input_init(void) case SYSTEM_LIGHTPHASER: { - if (player == MAX_INPUTS) return; input.dev[4] = DEVICE_LIGHTGUN; player++; break; @@ -218,7 +241,6 @@ void input_init(void) case SYSTEM_PADDLE: { - if (player == MAX_INPUTS) return; input.dev[4] = DEVICE_PADDLE; player++; break; @@ -226,7 +248,6 @@ void input_init(void) case SYSTEM_SPORTSPAD: { - if (player == MAX_INPUTS) return; input.dev[4] = DEVICE_SPORTSPAD; player++; break; @@ -239,9 +260,11 @@ void input_init(void) /* two additional gamepads */ for (i=5; i<7; i++) { - if (player == MAX_INPUTS) return; - input.dev[i] = config.input[player].padtype; - player ++; + if (player < MAX_INPUTS) + { + input.dev[i] = config.input[player].padtype; + player ++; + } } } } @@ -298,6 +321,12 @@ void input_reset(void) break; } + case DEVICE_TEREBI: + { + terebi_oekaki_reset(); + break; + } + default: { break; diff --git a/source/input_hw/input.h b/source/input_hw/input.h index 86ad507..48c6431 100644 --- a/source/input_hw/input.h +++ b/source/input_hw/input.h @@ -3,21 +3,37 @@ * Input peripherals support * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -39,21 +55,22 @@ #define SYSTEM_LIGHTPHASER (8) /* Sega Light Phaser (Master System) */ #define SYSTEM_PADDLE (9) /* Sega Paddle Control (Master System) */ #define SYSTEM_SPORTSPAD (10) /* Sega Sports Pad (Master System) */ -#define SYSTEM_TEAMPLAYER (11) /* Sega TeamPlayer */ -#define SYSTEM_WAYPLAY (12) /* EA 4-Way Play (use both ports) */ +#define SYSTEM_TEAMPLAYER (11) /* Multi Tap -- Sega TeamPlayer */ +#define SYSTEM_WAYPLAY (12) /* Multi Tap -- EA 4-Way Play (use both ports) */ /* Device type */ -#define DEVICE_PAD3B (0x00) /* 3-buttons Control Pad */ -#define DEVICE_PAD6B (0x01) /* 6-buttons Control Pad */ -#define DEVICE_MOUSE (0x02) /* Sega Mouse */ -#define DEVICE_XE_A1P (0x03) /* XE-A1P analog controller */ -#define DEVICE_ACTIVATOR (0x04) /* Activator */ -#define DEVICE_LIGHTGUN (0x05) /* Sega Light Phaser, Menacer or Konami Justifiers */ -#define DEVICE_PAD2B (0x06) /* 2-buttons Control Pad */ -#define DEVICE_PADDLE (0x07) /* Sega Paddle Control */ -#define DEVICE_SPORTSPAD (0x08) /* Sega Sports Pad */ -#define DEVICE_TABLET (0x09) /* PICO tablet & pen */ -#define NO_DEVICE (0xff) /* unconnected device */ +#define NO_DEVICE (0xff) /* unconnected device (fixed ID for Team Player) */ +#define DEVICE_PAD3B (0x00) /* 3-buttons Control Pad (fixed ID for Team Player)*/ +#define DEVICE_PAD6B (0x01) /* 6-buttons Control Pad (fixed ID for Team Player) */ +#define DEVICE_PAD2B (0x02) /* 2-buttons Control Pad */ +#define DEVICE_MOUSE (0x03) /* Sega Mouse */ +#define DEVICE_LIGHTGUN (0x04) /* Sega Light Phaser, Menacer or Konami Justifiers */ +#define DEVICE_PADDLE (0x05) /* Sega Paddle Control */ +#define DEVICE_SPORTSPAD (0x06) /* Sega Sports Pad */ +#define DEVICE_PICO (0x07) /* PICO tablet */ +#define DEVICE_TEREBI (0x08) /* Terebi Oekaki tablet */ +#define DEVICE_XE_A1P (0x09) /* XE-A1P analog controller */ +#define DEVICE_ACTIVATOR (0x0a) /* Activator */ /* Default Input bitmasks */ #define INPUT_MODE (0x0800) diff --git a/source/input_hw/lightgun.c b/source/input_hw/lightgun.c index d9dc6f2..22414ad 100644 --- a/source/input_hw/lightgun.c +++ b/source/input_hw/lightgun.c @@ -2,21 +2,37 @@ * Genesis Plus * Sega Light Phaser, Menacer & Konami Justifiers support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -96,7 +112,7 @@ void lightgun_refresh(int port) /* External Interrupt ? */ if (reg[11] & 0x08) { - m68k_irq_state |= 0x12; + m68k_update_irq(2); } /* HV Counter Latch: @@ -126,14 +142,14 @@ void lightgun_refresh(int port) static inline unsigned char phaser_read(int port) { - /* FIRE button status (active low) */ - unsigned char temp = ~(input.pad[port] & 0x10); + /* TL returns TRIGGER (INPUT_A) button status (active low) */ + unsigned char temp = ~((input.pad[port] >> 2) & 0x10); /* Check that TH is set as an input */ - if (io_reg[0] & (0x02 << (port >> 1))) + if (io_reg[0x0F] & (0x02 << (port >> 1))) { /* Get current X position (phaser is only used in MS compatiblity mode) */ - int hcounter = hctab[(mcycles_z80 + Z80_CYCLE_OFFSET) % MCYCLES_PER_LINE]; + int hcounter = hctab[(mcycles_z80 + SMS_CYCLE_OFFSET) % MCYCLES_PER_LINE]; /* Compare with gun position */ int dx = input.analog[port][0] - (hcounter << 1); @@ -179,9 +195,11 @@ unsigned char phaser_2_read(void) unsigned char menacer_read(void) { - /* Return START,A,B,C buttons status in D0-D3 (active high) */ - /* TL & TR pins always return 0 (normally set as output) */ - return ((input.pad[4] >> 4) & 0x0F); + /* D0=??? (INPUT_B), D1=TRIGGER (INPUT_A), D2=??? (INPUT_C), D3= START (INPUT_START) (active high) */ + /* TL & TR pins always return 0 (normally set as output) */ + /* TH always return 1 (0 on active pixel but button acquisition is always done during VBLANK) */ + unsigned data = input.pad[4] >> 4; + return ((data & 0x09) | ((data >> 1) & 0x02) | ((data << 1) & 0x04) | 0x40); } @@ -197,7 +215,7 @@ unsigned char justifier_read(void) return 0x30; } - /* Return A & START button status in D0-D1 (active low) */ + /* Return TRIGGER (INPUT_A) & START (INPUT_START) button status in D0-D1 (active low) */ /* TL & TR pins should always return 1 (normally set as output) */ /* LEFT & RIGHT pins should always return 0 */ return (((~input.pad[lightgun.Port] >> 6) & 0x03) | 0x70); @@ -205,8 +223,8 @@ unsigned char justifier_read(void) void justifier_write(unsigned char data, unsigned char mask) { - /* update bits set as output only */ - data = (lightgun.State & ~mask) | (data & mask); + /* update bits set as output only, other bits are cleared (fixes Lethal Enforcers 2) */ + data &= mask; /* gun index */ lightgun.Port = 4 + ((data >> 5) & 1); diff --git a/source/input_hw/lightgun.h b/source/input_hw/lightgun.h index 6a9fb08..4a67946 100644 --- a/source/input_hw/lightgun.h +++ b/source/input_hw/lightgun.h @@ -2,21 +2,37 @@ * Genesis Plus * Sega Light Phaser, Menacer & Konami Justifiers support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/mouse.c b/source/input_hw/mouse.c index 21c485b..c1db5d6 100644 --- a/source/input_hw/mouse.c +++ b/source/input_hw/mouse.c @@ -2,21 +2,37 @@ * Genesis Plus * Sega Mouse support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/mouse.h b/source/input_hw/mouse.h index 145d60f..6657d2a 100644 --- a/source/input_hw/mouse.h +++ b/source/input_hw/mouse.h @@ -2,21 +2,37 @@ * Genesis Plus * Sega Mouse support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/paddle.c b/source/input_hw/paddle.c index 53a9edb..f8b681c 100644 --- a/source/input_hw/paddle.c +++ b/source/input_hw/paddle.c @@ -2,21 +2,37 @@ * Genesis Plus * Sega Paddle Control support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/paddle.h b/source/input_hw/paddle.h index 8f8978b..926e947 100644 --- a/source/input_hw/paddle.h +++ b/source/input_hw/paddle.h @@ -2,21 +2,37 @@ * Genesis Plus * Sega Paddle Control support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/sportspad.c b/source/input_hw/sportspad.c index 2006508..6c85554 100644 --- a/source/input_hw/sportspad.c +++ b/source/input_hw/sportspad.c @@ -2,21 +2,37 @@ * Genesis Plus * Sega Sports Pad support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/sportspad.h b/source/input_hw/sportspad.h index 55aaa08..139b862 100644 --- a/source/input_hw/sportspad.h +++ b/source/input_hw/sportspad.h @@ -2,21 +2,37 @@ * Genesis Plus * Sega Sports Pad support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/teamplayer.c b/source/input_hw/teamplayer.c index e1fd927..85c9a33 100644 --- a/source/input_hw/teamplayer.c +++ b/source/input_hw/teamplayer.c @@ -2,21 +2,37 @@ * Genesis Plus * Team Player support * - * Copyright Eke-Eke (2007-2011) -* - * 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. + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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 + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/teamplayer.h b/source/input_hw/teamplayer.h index cb0c181..6e53c31 100644 --- a/source/input_hw/teamplayer.h +++ b/source/input_hw/teamplayer.h @@ -2,21 +2,37 @@ * Genesis Plus * Team Player support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/terebi_oekaki.c b/source/input_hw/terebi_oekaki.c new file mode 100644 index 0000000..bfcabc1 --- /dev/null +++ b/source/input_hw/terebi_oekaki.c @@ -0,0 +1,77 @@ +/*************************************************************************************** + * Genesis Plus + * Terebi Oekaki graphic board support + * + * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#include "shared.h" + +static struct +{ + uint8 axis; + uint8 busy; +} tablet; + +void terebi_oekaki_reset(void) +{ + input.analog[0][0] = 128; + input.analog[0][1] = 128; + tablet.axis = 1; + tablet.busy = 1; +} + +unsigned short terebi_oekaki_read(void) +{ + uint16 data = (tablet.busy << 15) | input.analog[0][tablet.axis]; + + if (!(input.pad[0] & INPUT_B)) + { + data |= 0x100; + } + + /* clear BUSY flag */ + tablet.busy = 0; + + return data; +} + +void terebi_oekaki_write(unsigned char data) +{ + /* X (1) or Y (0) axis */ + tablet.axis = (data & 1) ^ 1; + + /* set BUSY flag */ + tablet.busy = 1; +} \ No newline at end of file diff --git a/source/input_hw/terebi_oekaki.h b/source/input_hw/terebi_oekaki.h new file mode 100644 index 0000000..4a05c41 --- /dev/null +++ b/source/input_hw/terebi_oekaki.h @@ -0,0 +1,47 @@ +/*************************************************************************************** + * Genesis Plus + * Sega Paddle Control support + * + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#ifndef _TEREBI_H_ +#define _TEREBI_H_ + +/* Function prototypes */ +extern void terebi_oekaki_reset(void); +extern unsigned short terebi_oekaki_read(void); +extern void terebi_oekaki_write(unsigned char data); + +#endif diff --git a/source/input_hw/xe_a1p.c b/source/input_hw/xe_a1p.c index 3c7d437..859904b 100644 --- a/source/input_hw/xe_a1p.c +++ b/source/input_hw/xe_a1p.c @@ -2,21 +2,37 @@ * Genesis Plus * XE-A1P analog controller support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/input_hw/xe_a1p.h b/source/input_hw/xe_a1p.h index 189223b..66b0360 100644 --- a/source/input_hw/xe_a1p.h +++ b/source/input_hw/xe_a1p.h @@ -2,21 +2,37 @@ * Genesis Plus * XE-A1P analog controller support * - * Copyright Eke-Eke (2007-2011) + * Copyright (C) 2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ diff --git a/source/io_ctrl.c b/source/io_ctrl.c index 29f92cb..f046024 100644 --- a/source/io_ctrl.c +++ b/source/io_ctrl.c @@ -1,23 +1,41 @@ /*************************************************************************************** * Genesis Plus - * I/O controller (MD & MS compatibility modes) + * I/O controller (Genesis & Master System modes) + * + * Support for Master System (315-5216, 315-5237 & 315-5297), Game Gear & Mega Drive I/O chips * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -51,7 +69,7 @@ static unsigned char dummy_read(void) } /***************************************************************************** - * I/O chip functions * + * I/O chip initialization * * * *****************************************************************************/ void io_init(void) @@ -236,15 +254,9 @@ void io_init(void) void io_reset(void) { /* Reset I/O registers */ - if (system_hw == SYSTEM_PBC) + if (system_hw == SYSTEM_MD) { - /* SMS compatibility mode control register */ - io_reg[0x00] = 0xFF; - } - else - { - /* Genesis mode registers */ - io_reg[0x00] = region_code | 0x20 | (config.tmss & 1); + io_reg[0x00] = 0x20 | region_code | (config.tmss & 1); io_reg[0x01] = 0x00; io_reg[0x02] = 0x00; io_reg[0x03] = 0x00; @@ -261,11 +273,41 @@ void io_reset(void) io_reg[0x0E] = 0x00; io_reg[0x0F] = 0x00; } + else + { + /* Game Gear specific registers */ + io_reg[0x00] = 0x80 | (region_code >> 1); + io_reg[0x01] = 0x00; + io_reg[0x02] = 0xFF; + io_reg[0x03] = 0x00; + io_reg[0x04] = 0xFF; + io_reg[0x05] = 0x00; + io_reg[0x06] = 0xFF; + + /* initial !RESET input */ + io_reg[0x0D] = IO_RESET_HI; + + /* default !CONT input */ + if (system_hw != SYSTEM_PBC) + { + io_reg[0x0D] |= IO_CONT1_HI; + } + + /* Control registers */ + io_reg[0x0E] = 0x00; + io_reg[0x0F] = 0xFF; + } /* Reset connected peripherals */ input_reset(); } + +/***************************************************************************** + * I/O ports access from 68k (Genesis mode) * + * * + *****************************************************************************/ + void io_68k_write(unsigned int offset, unsigned int data) { switch (offset) @@ -334,45 +376,78 @@ unsigned int io_68k_read(unsigned int offset) } } -void io_z80_write(unsigned int data) + +/***************************************************************************** + * I/O ports access from Z80 * + * * + *****************************************************************************/ + +void io_z80_write(unsigned int offset, unsigned int data, unsigned int cycles) { -/* pins can't be configured as output on japanese models */ - if (region_code & REGION_USA) + if (offset) { - /* - Bit Function - -------------- - D7 : Port B TH pin output level (1=high, 0=low) - D6 : Port B TR pin output level (1=high, 0=low) - D5 : Port A TH pin output level (1=high, 0=low) - D4 : Port A TR pin output level (1=high, 0=low) - D3 : Port B TH pin direction (1=input, 0=output) - D2 : Port B TR pin direction (1=input, 0=output) - D1 : Port A TH pin direction (1=input, 0=output) - D0 : Port A TR pin direction (1=input, 0=output) - */ - - /* Send TR/TH state to connected peripherals */ - port[0].data_w((data << 1) & 0x60, (~io_reg[0] << 5) & 0x60); - port[1].data_w((data >> 1) & 0x60, (~io_reg[0] << 3) & 0x60); - - - /* Check for TH low-to-high transitions on both ports */ - if ((!(io_reg[0] & 0x80) && (data & 0x80)) || - (!(io_reg[0] & 0x20) && (data & 0x20))) + /* I/O Control register */ + if (region_code & REGION_USA) { - /* Latch new HVC */ - hvc_latch = hctab[(mcycles_z80 + Z80_CYCLE_OFFSET) % MCYCLES_PER_LINE] | 0x10000; + /* + Bit Function + -------------- + D7 : Port B TH pin output level (1=high, 0=low) + D6 : Port B TR pin output level (1=high, 0=low) + D5 : Port A TH pin output level (1=high, 0=low) + D4 : Port A TR pin output level (1=high, 0=low) + D3 : Port B TH pin direction (1=input, 0=output) + D2 : Port B TR pin direction (1=input, 0=output) + D1 : Port A TH pin direction (1=input, 0=output) + D0 : Port A TR pin direction (1=input, 0=output) + */ + + /* Send TR/TH state to connected peripherals */ + port[0].data_w((data << 1) & 0x60, (~io_reg[0x0F] << 5) & 0x60); + port[1].data_w((data >> 1) & 0x60, (~io_reg[0x0F] << 3) & 0x60); + + + /* Check for TH low-to-high transitions on both ports */ + if ((!(io_reg[0x0F] & 0x80) && (data & 0x80)) || + (!(io_reg[0x0F] & 0x20) && (data & 0x20))) + { + /* Latch new HVC */ + hvc_latch = hctab[cycles % MCYCLES_PER_LINE] | 0x10000; + } + + /* Update I/O Control register */ + io_reg[0x0F] = data; + } + else + { + /* TH output is fixed to 0 & TR is always an input on japanese hardware */ + io_reg[0x0F] = (data | 0x05) & 0x5F; + + /* Port $DD bits D4-D5 return D0-D2 (cf. http://www2.odn.ne.jp/~haf09260/Sms/EnrSms.htm) */ + io_reg[0x0D] = ((data & 0x01) << 4) | ((data & 0x04) << 3); } } else { - /* outputs return fixed value */ - data &= 0x0F; - } + /* Memory Control register */ + if (data & 0x40) + { + /* Assume only BIOS would disable Cartridge ROM */ + if (data & 0x08) + { + /* BIOS ROM disabled */ + sms_cart_switch(0); + } + else + { + /* BIOS ROM enabled */ + sms_cart_switch(1); + } + } - /* Update control register */ - io_reg[0] = data; + /* Update Memory Control register */ + io_reg[0x0E] = data; + } } unsigned int io_z80_read(unsigned int offset) @@ -380,8 +455,8 @@ unsigned int io_z80_read(unsigned int offset) /* Read port A & port B input data */ unsigned int data = (port[0].data_r()) | (port[1].data_r() << 8); - /* Read control register value */ - unsigned int ctrl = io_reg[0]; + /* I/O control register value */ + unsigned int ctrl = io_reg[0x0F]; /* I/O ports */ if (offset) @@ -391,14 +466,17 @@ unsigned int io_z80_read(unsigned int offset) -------------- D7 : Port B TH pin input D6 : Port A TH pin input - D5 : Unused (0 on Mega Drive, 1 otherwise) - D4 : RESET button (always 1 on Mega Drive) + D5 : CONT input (0 on Mega Drive hardware, 1 otherwise) + D4 : RESET button (1: default, 0: pressed, only on Master System hardware) D3 : Port B TR pin input D2 : Port B TL pin input D1 : Port B Right pin input D0 : Port B Left pin input */ - data = ((data >> 10) & 0x0F) | (data & 0x40) | ((data >> 7) & 0x80) | 0x10; + data = ((data >> 10) & 0x0F) | (data & 0x40) | ((data >> 7) & 0x80) | io_reg[0x0D]; + + /* clear !RESET input */ + io_reg[0x0D] |= IO_RESET_HI; /* Adjust port B TH state if configured as output */ if (!(ctrl & 0x08)) @@ -448,3 +526,65 @@ unsigned int io_z80_read(unsigned int offset) return data; } + +/***************************************************************************** + * Game Gear communication ports access * + * * + *****************************************************************************/ + +void io_gg_write(unsigned int offset, unsigned int data) +{ + switch (offset) + { + case 1: /* Parallel data register */ + io_reg[1] = data; + return; + + case 2: /* Data direction register and NMI enable */ + io_reg[2] = data; + return; + + case 3: /* Transmit data buffer */ + io_reg[3] = data; + return; + + case 5: /* Serial control (bits 0-2 are read-only) */ + io_reg[5] = data & 0xF8; + return; + + case 6: /* PSG Stereo output control (unsupported) */ + io_reg[6] = data; + return; + + default: /* Read-only */ + return; + } +} + +unsigned int io_gg_read(unsigned int offset) +{ + switch (offset) + { + case 0: /* Mode Register */ + return (io_reg[0] & ~(input.pad[0] & INPUT_START)); + + case 1: /* Parallel data register (not connected) */ + return ((io_reg[1] & ~(io_reg[2] & 0x7F)) | (io_reg[2] & 0x7F)); + + case 2: /* Data direction register and NMI enable */ + return io_reg[2]; + + case 3: /* Transmit data buffer */ + return io_reg[3]; + + case 4: /* Receive data buffer */ + return io_reg[4]; + + case 5: /* Serial control */ + return io_reg[5]; + + default: /* Write-Only */ + return 0xFF; + } +} + diff --git a/source/io_ctrl.h b/source/io_ctrl.h index 853524f..460aa0e 100644 --- a/source/io_ctrl.h +++ b/source/io_ctrl.h @@ -1,28 +1,49 @@ /*************************************************************************************** * Genesis Plus - * I/O controller (MD & MS compatibility modes) + * I/O controller + * + * Support for Master System (315-5216, 315-5237 & 315-5297), Game Gear & Mega Drive I/O chips * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ -#ifndef _GEN_IO_H_ -#define _GEN_IO_H_ +#ifndef _IO_CTRL_H_ +#define _IO_CTRL_H_ + +#define IO_RESET_HI 0x10 +#define IO_CONT1_HI 0x20 #define REGION_JAPAN_NTSC 0x00 #define REGION_JAPAN_PAL 0x40 @@ -38,8 +59,10 @@ extern void io_init(void); extern void io_reset(void); extern void io_68k_write(unsigned int offset, unsigned int data); extern unsigned int io_68k_read(unsigned int offset); -extern void io_z80_write(unsigned int data); +extern void io_z80_write(unsigned int offset, unsigned int data, unsigned int cycles); extern unsigned int io_z80_read(unsigned int offset); +extern void io_gg_write(unsigned int offset, unsigned int data); +extern unsigned int io_gg_read(unsigned int offset); -#endif /* _IO_H_ */ +#endif /* _IO_CTRL_H_ */ diff --git a/source/loadrom.c b/source/loadrom.c index 403f81d..f281daa 100644 --- a/source/loadrom.c +++ b/source/loadrom.c @@ -3,21 +3,37 @@ * ROM Loading Support * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -75,7 +91,7 @@ typedef struct ROMINFO rominfo; char rom_filename[256]; - +uint8 romtype; /*************************************************************************** * Genesis ROM Manufacturers @@ -220,9 +236,6 @@ static void getrominfo(char *romheader) /* If found, assume this is a SMS game */ if (offset) { - /* force SMS compatibilty mode */ - system_hw = SYSTEM_PBC; - /* checksum */ rominfo.checksum = cart.rom[offset + 0x0a] | (cart.rom[offset + 0x0b] << 8); @@ -291,7 +304,7 @@ static void getrominfo(char *romheader) else { /* Some SMS games don't have any header */ - if (system_hw == SYSTEM_PBC) return; + if (system_hw != SYSTEM_MD) return; /* Genesis ROM header support */ memcpy (&rominfo.consoletype, romheader + ROMCONSOLE, 16); @@ -367,38 +380,48 @@ static void deinterleave_block(uint8 * src) * load_rom * * Load a new ROM file. + * + * Return 0 on error, 1 on success + * ***************************************************************************/ int load_rom(char *filename) { - int i, size; - -#ifdef NGC - size = cart.romsize; -#else - uint8 *ptr; - ptr = load_archive(filename, &size); - if(!ptr) return (0); - memcpy(cart.rom, ptr, size); - free(ptr); -#endif + int i; - /* Minimal ROM size */ - if (size < 0x4000) - { - memset(cart.rom + size, 0xFF, 0x4000 - size); - size = 0x4000; - } + /* Load file into ROM buffer */ + int size = load_archive(filename); + if (!size) return(0); - /* Get file extension */ + /* Auto-detect system mode from ROM file extension */ if (!strnicmp(".sms", &filename[strlen(filename) - 4], 4)) { - /* Force SMS compatibility mode */ - system_hw = SYSTEM_PBC; + /* Master System II hardware */ + system_hw = SYSTEM_SMS2; + } + else if (!strnicmp(".gg", &filename[strlen(filename) - 3], 3)) + { + /* Game Gear hardware (GG mode) */ + system_hw = SYSTEM_GG; + } + else if (!strnicmp(".sg", &filename[strlen(filename) - 3], 3)) + { + /* SG-1000 hardware */ + system_hw = SYSTEM_SG; } else { - /* Assume Genesis mode */ - system_hw = SYSTEM_GENESIS; + /* Mega Drive hardware (Genesis mode) */ + system_hw = SYSTEM_MD; + + /* Decode .MDX format */ + if (!strnicmp(".mdx", &filename[strlen(filename) - 4], 4)) + { + for (i = 4; i < size - 1; i++) + { + cart.rom[i-4] = cart.rom[i] ^ 0x40; + } + size = size - 5; + } } /* Take care of 512 byte header, if present */ @@ -408,7 +431,7 @@ int load_rom(char *filename) memcpy (cart.rom, cart.rom + 512, size); /* interleaved ROM format (.smd) */ - if (system_hw != SYSTEM_PBC) + if (system_hw == SYSTEM_MD) { for (i = 0; i < (size / 0x4000); i++) { @@ -427,14 +450,45 @@ int load_rom(char *filename) /* get infos from ROM header */ getrominfo((char *)cart.rom); + /* PICO hardware */ + if (strstr(rominfo.consoletype, "SEGA PICO") != NULL) + { + system_hw = SYSTEM_PICO; + } + /* detect console region */ region_autodetect(); - /* Genesis ROM specific */ - if (system_hw != SYSTEM_PBC) + /* Save ROM type for later use */ + romtype = system_hw; + + /* Force system if requested */ + if (config.system == SYSTEM_MD) + { + if (!(system_hw & SYSTEM_MD)) + { + /* Mega Drive in MS compatibility mode */ + system_hw = SYSTEM_PBC; + } + } + else if (config.system == SYSTEM_GG) + { + if (!(system_hw == SYSTEM_GG)) + { + /* Game Gear in MS compatibility mode */ + system_hw = SYSTEM_GGMS; + } + } + else if (config.system) + { + system_hw = config.system; + } + + /* Genesis mode specific */ + if (system_hw == SYSTEM_MD) { #ifdef LSB_FIRST - /* Byteswap ROM */ + /* Byteswap ROM to optimize 16-bit access */ uint8 temp; for(i = 0; i < size; i += 2) { @@ -456,12 +510,6 @@ int load_rom(char *filename) cart.rom[i+1] = temp; } } - - /* PICO hardware */ - if (strstr(rominfo.consoletype, "SEGA PICO") != NULL) - { - system_hw = SYSTEM_PICO; - } } return(1); @@ -475,7 +523,7 @@ int load_rom(char *filename) ****************************************************************************/ void region_autodetect(void) { - if (system_hw == SYSTEM_PBC) + if (system_hw != SYSTEM_MD) { region_code = sms_cart_region_detect(); } diff --git a/source/loadrom.h b/source/loadrom.h index e1f89a1..ae5a980 100644 --- a/source/loadrom.h +++ b/source/loadrom.h @@ -3,23 +3,40 @@ * ROM Loading Support * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ + #ifndef _LOADROM_H_ #define _LOADROM_H_ @@ -45,6 +62,7 @@ typedef struct /* Global variables */ extern ROMINFO rominfo; extern char rom_filename[256]; +extern uint8 romtype; /* Function prototypes */ extern int load_rom(char *filename); diff --git a/source/m68k/m68k.h b/source/m68k/m68k.h index 5c8571a..295d377 100644 --- a/source/m68k/m68k.h +++ b/source/m68k/m68k.h @@ -22,6 +22,18 @@ * http://kstenerud.cjb.net */ + /* Modified by Eke-Eke for Genesis Plus GX: + + - removed unused stuff to reduce memory usage / optimize execution (multiple CPU types support, NMI support, ...) + - moved stuff to compile statically in a single object file + - implemented support for global cycle count (shared by 68k & Z80 CPU) + - added support for interrupt latency (Sesame's Street Counting Cafe, Fatal Rewind) + - added proper cycle use on reset + - added cycle accurate timings for MUL/DIV instructions (thanks to Jorge Cwik !) + - fixed undocumented flags for DIV instructions (Blood Shot) + + */ + /* ======================================================================== */ /* ============================= CONFIGURATION ============================ */ /* ======================================================================== */ @@ -66,19 +78,6 @@ #define M68K_INT_ACK_SPURIOUS 0xfffffffe -/* CPU types for use in m68k_set_cpu_type() */ -enum -{ - M68K_CPU_TYPE_INVALID, - M68K_CPU_TYPE_68000, - M68K_CPU_TYPE_68008, - M68K_CPU_TYPE_68010, - M68K_CPU_TYPE_68EC020, - M68K_CPU_TYPE_68020, - M68K_CPU_TYPE_68030, /* Supported by disassembler ONLY */ - M68K_CPU_TYPE_68040 /* Supported by disassembler ONLY */ -}; - /* Registers used by m68k_get_reg() and m68k_set_reg() */ typedef enum { @@ -102,82 +101,42 @@ typedef enum M68K_REG_PC, /* Program Counter */ M68K_REG_SR, /* Status Register */ M68K_REG_SP, /* The current Stack Pointer (located in A7) */ - M68K_REG_USP, /* User Stack Pointer */ - M68K_REG_ISP, /* Interrupt Stack Pointer */ - M68K_REG_MSP, /* Master Stack Pointer */ - M68K_REG_SFC, /* Source Function Code */ - M68K_REG_DFC, /* Destination Function Code */ - M68K_REG_VBR, /* Vector Base Register */ - M68K_REG_CACR, /* Cache Control Register */ - M68K_REG_CAAR, /* Cache Address Register */ + M68K_REG_USP, /* User Stack Pointer */ + M68K_REG_ISP, /* Interrupt Stack Pointer */ +#if M68K_EMULATE_PREFETCH /* Assumed registers */ /* These are cheat registers which emulate the 1-longword prefetch - * present in the 68000 and 68010. - */ + * present in the 68000 and 68010. + */ M68K_REG_PREF_ADDR, /* Last prefetch address */ M68K_REG_PREF_DATA, /* Last prefetch data */ +#endif /* Convenience registers */ - M68K_REG_PPC, /* Previous value in the program counter */ M68K_REG_IR, /* Instruction register */ - M68K_REG_CPU_TYPE /* Type of CPU being run */ } m68k_register_t; + /* ======================================================================== */ /* ====================== FUNCTIONS CALLED BY THE CPU ===================== */ /* ======================================================================== */ -/* You will have to implement these functions */ - -/* read/write functions called by the CPU to access memory. - * while values used are 32 bits, only the appropriate number - * of bits are relevant (i.e. in write_memory_8, only the lower 8 bits - * of value should be written to memory). - * - * NOTE: I have separated the immediate and PC-relative memory fetches - * from the other memory fetches because some systems require - * differentiation between PROGRAM and DATA fetches (usually - * for security setups such as encryption). - * This separation can either be achieved by setting - * M68K_SEPARATE_READS in m68kconf.h and defining - * the read functions, or by setting M68K_EMULATE_FC and - * making a function code callback function. - * Using the callback offers better emulation coverage - * because you can also monitor whether the CPU is in SYSTEM or - * USER mode, but it is also slower. - */ - -/* Read from anywhere */ -unsigned int m68k_read_memory_8(unsigned int address); -unsigned int m68k_read_memory_16(unsigned int address); -unsigned int m68k_read_memory_32(unsigned int address); - -/* Memory access for the disassembler */ -unsigned int m68k_read_disassembler_8 (unsigned int address); -unsigned int m68k_read_disassembler_16 (unsigned int address); -unsigned int m68k_read_disassembler_32 (unsigned int address); - -/* Write to anywhere */ -void m68k_write_memory_8(unsigned int address, unsigned int value); -void m68k_write_memory_16(unsigned int address, unsigned int value); -void m68k_write_memory_32(unsigned int address, unsigned int value); - - #include "macros.h" +/* 68k memory map structure */ typedef struct { - unsigned char *base; - unsigned int (*read8)(unsigned int address); - unsigned int (*read16)(unsigned int address); - void (*write8)(unsigned int address, unsigned int data); - void (*write16)(unsigned int address, unsigned int data); + unsigned char *base; /* direct memory access (ROM, RAM) */ + unsigned int (*read8)(unsigned int address); /* I/O byte read access */ + unsigned int (*read16)(unsigned int address); /* I/O word read access */ + void (*write8)(unsigned int address, unsigned int data); /* I/O byte write access */ + void (*write16)(unsigned int address, unsigned int data); /* I/O word write access */ } _m68k_memory_map; +/* 68k memory map */ _m68k_memory_map m68k_memory_map[256]; - /* Read data immediately following the PC */ #define m68k_read_immediate_16(address) *(uint16 *)(m68k_memory_map[((address)>>16)&0xff].base + ((address) & 0xffff)) #define m68k_read_immediate_32(address) (m68k_read_immediate_16(address) << 16) | (m68k_read_immediate_16(address+2)) @@ -187,16 +146,6 @@ _m68k_memory_map m68k_memory_map[256]; #define m68k_read_pcrelative_16(address) m68k_read_immediate_16(address) #define m68k_read_pcrelative_32(address) m68k_read_immediate_32(address) -/* Special call to simulate undocumented 68k behavior when move.l with a - * predecrement destination mode is executed. - * To simulate real 68k behavior, first write the high word to - * [address+2], and then write the low word to [address]. - * - * Enable this functionality with M68K_SIMULATE_PD_WRITES in m68kconf.h. - */ -void m68k_write_memory_32_pd(unsigned int address, unsigned int value); - - /* ======================================================================== */ /* ============================== CALLBACKS =============================== */ @@ -210,6 +159,7 @@ void m68k_write_memory_32_pd(unsigned int address, unsigned int value); * callback or have assigned a callback of NULL. */ +#if M68K_EMULATE_INT_ACK == OPT_ON /* Set the callback for an interrupt acknowledge. * You must enable M68K_EMULATE_INT_ACK in m68kconf.h. * The CPU will call the callback with the interrupt level being acknowledged. @@ -221,58 +171,27 @@ void m68k_write_memory_32_pd(unsigned int address, unsigned int value); * Default behavior: return M68K_INT_ACK_AUTOVECTOR. */ void m68k_set_int_ack_callback(int (*callback)(int int_level)); +#endif - -/* Set the callback for a breakpoint acknowledge (68010+). - * You must enable M68K_EMULATE_BKPT_ACK in m68kconf.h. - * The CPU will call the callback with whatever was in the data field of the - * BKPT instruction for 68020+, or 0 for 68010. - * Default behavior: do nothing. - */ -void m68k_set_bkpt_ack_callback(void (*callback)(unsigned int data)); - - +#if M68K_EMULATE_RESET == OPT_ON /* Set the callback for the RESET instruction. * You must enable M68K_EMULATE_RESET in m68kconf.h. * The CPU calls this callback every time it encounters a RESET instruction. * Default behavior: do nothing. */ void m68k_set_reset_instr_callback(void (*callback)(void)); +#endif - -/* Set the callback for the CMPI.L #v, Dn instruction. - * You must enable M68K_CMPILD_HAS_CALLBACK in m68kconf.h. - * The CPU calls this callback every time it encounters a CMPI.L #v, Dn instruction. - * Default behavior: do nothing. - */ -void m68k_set_cmpild_instr_callback(void (*callback)(unsigned int val, int reg)); - - -/* Set the callback for the RTE instruction. - * You must enable M68K_RTE_HAS_CALLBACK in m68kconf.h. - * The CPU calls this callback every time it encounters a RTE instruction. - * Default behavior: do nothing. - */ -void m68k_set_rte_instr_callback(void (*callback)(void)); - +#if M68K_TAS_HAS_CALLBACK == OPT_ON /* Set the callback for the TAS instruction. * You must enable M68K_TAS_HAS_CALLBACK in m68kconf.h. * The CPU calls this callback every time it encounters a TAS instruction. * Default behavior: return 1, allow writeback. */ void m68k_set_tas_instr_callback(int (*callback)(void)); +#endif - - -/* Set the callback for informing of a large PC change. - * You must enable M68K_MONITOR_PC in m68kconf.h. - * The CPU calls this callback with the new PC value every time the PC changes - * by a large value (currently set for changes by longwords). - * Default behavior: do nothing. - */ -void m68k_set_pc_changed_callback(void (*callback)(unsigned int new_pc)); - - +#if M68K_EMULATE_FC == OPT_ON /* Set the callback for CPU function code changes. * You must enable M68K_EMULATE_FC in m68kconf.h. * The CPU calls this callback with the function code before every memory @@ -281,115 +200,46 @@ void m68k_set_pc_changed_callback(void (*callback)(unsigned int new_pc)); * Default behavior: do nothing. */ void m68k_set_fc_callback(void (*callback)(unsigned int new_fc)); - - -/* Set a callback for the instruction cycle of the CPU. - * You must enable M68K_INSTRUCTION_HOOK in m68kconf.h. - * The CPU calls this callback just before fetching the opcode in the - * instruction cycle. - * Default behavior: do nothing. - */ -void m68k_set_instr_hook_callback(void (*callback)(unsigned int pc)); - +#endif /* ======================================================================== */ /* ====================== FUNCTIONS TO ACCESS THE CPU ===================== */ /* ======================================================================== */ -/* Use this function to set the CPU type you want to emulate. - * Currently supported types are: M68K_CPU_TYPE_68000, M68K_CPU_TYPE_68008, - * M68K_CPU_TYPE_68010, M68K_CPU_TYPE_EC020, and M68K_CPU_TYPE_68020. - */ -void m68k_set_cpu_type(unsigned int cpu_type); - /* Do whatever initialisations the core requires. Should be called * at least once at init time. */ -void m68k_init(void); +extern void m68k_init(void); /* Pulse the RESET pin on the CPU. * You *MUST* reset the CPU at least once to initialize the emulation - * Note: If you didn't call m68k_set_cpu_type() before resetting - * the CPU for the first time, the CPU will be set to - * M68K_CPU_TYPE_68000. */ -void m68k_pulse_reset(void); +extern void m68k_pulse_reset(void); -/* execute num_cycles worth of instructions. returns number of cycles used */ -//int m68k_execute(int num_cycles); - -/* run until global cycle count is reached */ -void m68k_run(unsigned int cycles); - -/* These functions let you read/write/modify the number of cycles left to run - * while m68k_execute() is running. - * These are useful if the 68k accesses a memory-mapped port on another device - * that requires immediate processing by another CPU. - */ -//int m68k_cycles_run(void); /* Number of cycles run so far */ -//int m68k_cycles_remaining(void); /* Number of cycles left */ -//void m68k_modify_timeslice(int cycles); /* Modify cycles left */ -//void m68k_end_timeslice(void); /* End timeslice now */ +/* Run until given cycle count is reached */ +extern void m68k_run(unsigned int cycles); /* Set the IPL0-IPL2 pins on the CPU (IRQ). * A transition from < 7 to 7 will cause a non-maskable interrupt (NMI). * Setting IRQ to 0 will clear an interrupt request. */ -void m68k_set_irq(unsigned int int_level); - +extern void m68k_update_irq(unsigned int mask); +extern void m68k_set_irq(unsigned int int_level); +extern void m68k_set_irq_delay(unsigned int int_level); /* Halt the CPU as if you pulsed the HALT pin. */ -void m68k_pulse_halt(void); - - -/* Context switching to allow multiple CPUs */ - -/* Get the size of the cpu context in bytes */ -unsigned int m68k_context_size(void); - -/* Get a cpu context */ -unsigned int m68k_get_context(void* dst); - -/* set the current cpu context */ -void m68k_set_context(void* dst); - -/* Register the CPU state information */ -void m68k_state_register(const char *type, int index); +extern void m68k_pulse_halt(void); /* Peek at the internals of a CPU context. This can either be a context * retrieved using m68k_get_context() or the currently running context. * If context is NULL, the currently running CPU context will be used. */ -unsigned int m68k_get_reg(void* context, m68k_register_t reg); +extern unsigned int m68k_get_reg(m68k_register_t reg); /* Poke values into the internals of the currently running CPU context */ -void m68k_set_reg(m68k_register_t reg, unsigned int value); - -/* Check if an instruction is valid for the specified CPU type */ -unsigned int m68k_is_valid_instruction(unsigned int instruction, unsigned int cpu_type); - -/* Disassemble 1 instruction using the epecified CPU type at pc. Stores - * disassembly in str_buff and returns the size of the instruction in bytes. - */ -unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_type); - -/* Same as above but accepts raw opcode data directly rather than fetching - * via the read/write interfaces. - */ -unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type); - -/*** Not really required, but makes for clean compile under DevkitPPC ***/ -extern int vdp_68k_irq_ack(int int_level); - -/* ======================================================================== */ -/* ============================== MAME STUFF ============================== */ -/* ======================================================================== */ - -#if M68K_COMPILE_FOR_MAME == OPT_ON -#include "m68kmame.h" -#endif /* M68K_COMPILE_FOR_MAME */ +extern void m68k_set_reg(m68k_register_t reg, unsigned int value); /* ======================================================================== */ diff --git a/source/m68k/m68kCycleAccurate.h b/source/m68k/m68kCycleAccurate.h deleted file mode 100644 index 7a6ffd3..0000000 --- a/source/m68k/m68kCycleAccurate.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Compute exact number of CPU cycles taken - * by DIVU and DIVS on a 68000 processor. - * - * Copyright (c) 2005 by Jorge Cwik, pasti@fxatari.com - * - * Added MULU and MULS accurate timings (Eke-Eke) - * - * This 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 software 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 software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -/* - - The routines below take dividend and divisor as parameters. - They return 0 if division by zero, or exact number of cycles otherwise. - - The number of cycles returned assumes a register operand. - Effective address time must be added if memory operand. - - For 68000 only (not 68010, 68012, 68020, etc). - Probably valid for 68008 after adding the extra prefetch cycle. - - - Best and worst cases for register operand: - (Note the difference with the documented range.) - - - DIVU: - - Overflow (always): 10 cycles. - Worst case: 136 cycles. - Best case: 76 cycles. - - - DIVS: - - Absolute overflow: 16-18 cycles. - Signed overflow is not detected prematurely. - - Worst case: 156 cycles. - Best case without signed overflow: 122 cycles. - Best case with signed overflow: 120 cycles - - - */ - -#include - -// Change this depending on architecture -// This code assumes long is 32 bits and short is 16 bits - -typedef unsigned long DWORD; -typedef unsigned short WORD; -typedef signed long LONG; -typedef signed short SHORT; - -// -// DIVU -// Unsigned division -// - -INLINE unsigned getDivu68kCycles( DWORD dividend, WORD divisor) -{ - int i; - - //if( (WORD) divisor == 0) - // return 0; - - // Overflow - //if( (dividend >> 16) >= divisor) - // return (mcycles = 5) * 2; - - unsigned mcycles = 38; - DWORD hdivisor = ((DWORD) divisor) << 16; - - for( i = 0; i < 15; i++) - { - DWORD temp; - temp = dividend; - - dividend <<= 1; - - // If carry from shift - if( (LONG) temp < 0) - { - dividend -= hdivisor; - } - - else - { - mcycles += 2; - if( dividend >= hdivisor) - { - dividend -= hdivisor; - mcycles--; - } - } - } - - return mcycles * 14; -} - -// -// DIVS -// Signed division -// - -INLINE unsigned getDivs68kCycles( LONG dividend, SHORT divisor) -{ - - //if( (SHORT) divisor == 0) - // return 0; - - unsigned mcycles = 6; - - if( dividend < 0) - mcycles++; - - // Check for absolute overflow - if( ((DWORD) abs( dividend) >> 16) >= (WORD) abs( divisor)) - { - return (mcycles + 2) * 14; - } - - // Absolute quotient - unsigned aquot = (DWORD) abs( dividend) / (WORD) abs( divisor); - - mcycles += 55; - - if( divisor >= 0) - { - if( dividend >= 0) - mcycles--; - else - mcycles++; - } - - // Count 15 msbits in absolute of quotient - int i; - - for( i = 0; i < 15; i++) - { - if( (SHORT) aquot >= 0) - mcycles++; - aquot <<= 1; - } - - return mcycles * 14; -} - -// -// MULU -// Unsigned multiplication -// - -INLINE unsigned getMulu68kCycles( WORD source) -{ - unsigned mcycles = 266; - - /* count number of bits set to 1 */ - while (source) - { - if (source & 1) - { - mcycles += 14; - } - source >>= 1; - } - - /* 38 + 2*N */ - return mcycles; -} - -// -// MULS -// Signed multiplication -// - -INLINE unsigned getMuls68kCycles( SHORT source) -{ - unsigned mcycles = 266; - - /* detect 01 or 10 patterns */ - LONG temp = source << 1; - temp = (temp ^ source) & 0xFFFF; - - /* count number of bits set to 1 */ - while (temp) - { - if (temp & 1) - { - mcycles += 14; - } - temp >>= 1; - } - - /* 38 + 2*N */ - return mcycles; -} diff --git a/source/m68k/m68kconf.h b/source/m68k/m68kconf.h index cbd3cf6..d224a10 100644 --- a/source/m68k/m68kconf.h +++ b/source/m68k/m68kconf.h @@ -19,6 +19,17 @@ * http://kstenerud.cjb.net */ + /* Modified by Eke-Eke for Genesis Plus GX: + + - removed unused stuff to reduce memory usage / optimize execution (multiple CPU types support, NMI support, ...) + - moved stuff to compile statically in a single object file + - implemented support for global cycle count (shared by 68k & Z80 CPU) + - added support for interrupt latency (Sesame's Street Counting Cafe, Fatal Rewind) + - added proper cycle use on reset + - added cycle accurate timings for MUL/DIV instructions (thanks to Jorge Cwik !) + - fixed undocumented flags for DIV instructions (Blood Shot) + + */ #ifndef M68KCONF__HEADER @@ -35,40 +46,10 @@ #define OPT_ON 1 #define OPT_SPECIFY_HANDLER 2 - -/* ======================================================================== */ -/* ============================== MAME STUFF ============================== */ -/* ======================================================================== */ - -/* If you're compiling this for MAME, only change M68K_COMPILE_FOR_MAME - * to OPT_ON and use m68kmame.h to configure the 68k core. - */ -#ifndef M68K_COMPILE_FOR_MAME -#define M68K_COMPILE_FOR_MAME OPT_OFF -#endif /* M68K_COMPILE_FOR_MAME */ - - -#if M68K_COMPILE_FOR_MAME == OPT_OFF - - /* ======================================================================== */ /* ============================= CONFIGURATION ============================ */ /* ======================================================================== */ -/* Turn ON if you want to use the following M68K variants */ -#define M68K_EMULATE_008 OPT_OFF -#define M68K_EMULATE_010 OPT_OFF -#define M68K_EMULATE_EC020 OPT_OFF -#define M68K_EMULATE_020 OPT_OFF -#define M68K_EMULATE_040 OPT_OFF - - -/* If ON, the CPU will call m68k_read_immediate_xx() for immediate addressing - * and m68k_read_pcrelative_xx() for PC-relative addressing. - * If off, all read requests from the CPU will be redirected to m68k_read_xx() - */ -#define M68K_SEPARATE_READS OPT_ON - /* If ON, the CPU will call m68k_write_32_pd() when it executes move.l with a * predecrement destination EA mode instead of m68k_write_32(). * To simulate real 68k behavior, m68k_write_32_pd() must first write the high @@ -84,46 +65,18 @@ #define M68K_EMULATE_INT_ACK OPT_SPECIFY_HANDLER #define M68K_INT_ACK_CALLBACK(A) vdp_68k_irq_ack(A) - -/* If ON, CPU will call the breakpoint acknowledge callback when it encounters - * a breakpoint instruction and it is running a 68010+. - */ -#define M68K_EMULATE_BKPT_ACK OPT_OFF -#define M68K_BKPT_ACK_CALLBACK() your_bkpt_ack_handler_function() - - -/* If ON, the CPU will monitor the trace flags and take trace exceptions - */ -#define M68K_EMULATE_TRACE OPT_OFF - - /* If ON, CPU will call the output reset callback when it encounters a reset * instruction. */ #define M68K_EMULATE_RESET OPT_OFF #define M68K_RESET_CALLBACK() your_reset_handler_function() - -/* If ON, CPU will call the callback when it encounters a cmpi.l #v, dn - * instruction. - */ -#define M68K_CMPILD_HAS_CALLBACK OPT_OFF -#define M68K_CMPILD_CALLBACK(v,r) your_cmpild_handler_function(v,r) - - -/* If ON, CPU will call the callback when it encounters a rte - * instruction. - */ -#define M68K_RTE_HAS_CALLBACK OPT_OFF -#define M68K_RTE_CALLBACK() your_rte_handler_function() - /* If ON, CPU will call the callback when it encounters a tas * instruction. */ #define M68K_TAS_HAS_CALLBACK OPT_OFF #define M68K_TAS_CALLBACK() your_tas_handler_function() - /* If ON, CPU will call the set fc callback on every memory access to * differentiate between user/supervisor, program/data access like a real * 68000 would. This should be enabled and the callback should be set if you @@ -133,48 +86,26 @@ #define M68K_EMULATE_FC OPT_OFF #define M68K_SET_FC_CALLBACK(A) your_set_fc_handler_function(A) - -/* If ON, CPU will call the pc changed callback when it changes the PC by a - * large value. This allows host programs to be nicer when it comes to - * fetching immediate data and instructions on a banked memory system. +/* If ON, the CPU will monitor the trace flags and take trace exceptions */ -#define M68K_MONITOR_PC OPT_OFF -#define M68K_SET_PC_CALLBACK(A) your_pc_changed_handler_function(A) - - -/* If ON, CPU will call the instruction hook callback before every - * instruction. - */ -#define M68K_INSTRUCTION_HOOK OPT_OFF -#define M68K_INSTRUCTION_CALLBACK() your_instruction_hook_function() - +#define M68K_EMULATE_TRACE OPT_OFF /* If ON, the CPU will emulate the 4-byte prefetch queue of a real 68000 */ #define M68K_EMULATE_PREFETCH OPT_OFF - /* If ON, the CPU will generate address error exceptions if it tries to * access a word or longword at an odd address. * NOTE: This is only emulated properly for 68000 mode. */ #define M68K_EMULATE_ADDRESS_ERROR OPT_ON - -/* If ON, branch instructions will check for infinite loop and - * freeze current CPU execution . - * Unnecessary checking might be disabled to improve instruction - * emulation speed since infinite loops are going to "lock" the CPU - * execution anyway. +/* If ON and previous option is also ON, address error exceptions will + also be checked when fetching instructions. Disabling this can help + speeding up emulation while still emulating address error exceptions + on other memory access if needed. + * NOTE: This is only emulated properly for 68000 mode. */ -#define M68K_CHECK_INFINITE_LOOP OPT_OFF - -/* Turn ON to enable logging of illegal instruction calls. - * M68K_LOG_FILEHANDLE must be #defined to a stdio file stream. - * Turn on M68K_LOG_1010_1111 to log all 1010 and 1111 calls. - */ -#define M68K_LOG_ENABLE OPT_OFF -#define M68K_LOG_1010_1111 OPT_OFF -#define M68K_LOG_FILEHANDLE some_file_handle +#define M68K_CHECK_PC_ADDRESS_ERROR OPT_OFF /* ----------------------------- COMPATIBILITY ---------------------------- */ @@ -199,8 +130,6 @@ #define INLINE static __inline__ #endif /* INLINE */ -#endif /* M68K_COMPILE_FOR_MAME */ - /* ======================================================================== */ /* ============================== END OF FILE ============================= */ diff --git a/source/m68k/m68kcpu.c b/source/m68k/m68kcpu.c index 4b992e4..3b1fcd3 100644 --- a/source/m68k/m68kcpu.c +++ b/source/m68k/m68kcpu.c @@ -25,436 +25,31 @@ static const char copyright_notice[] = /* ======================================================================== */ /* ================================= NOTES ================================ */ /* ======================================================================== */ + + /* Modified by Eke-Eke for Genesis Plus GX: - + - removed unused stuff to reduce memory usage / optimize execution (multiple CPU types support, NMI support, ...) + - moved stuff to compile statically in a single object file + - implemented support for global cycle count (shared by 68k & Z80 CPU) + - added support for interrupt latency (Sesame's Street Counting Cafe, Fatal Rewind) + - added proper cycle use on reset + - added cycle accurate timings for MUL/DIV instructions (thanks to Jorge Cwik !) + - fixed undocumented flags for DIV instructions (Blood Shot) + + */ /* ======================================================================== */ /* ================================ INCLUDES ============================== */ /* ======================================================================== */ -#include "m68kops.h" #include "m68kcpu.h" - -#if M68K_EMULATE_040 -#include "m68kfpu.c" -extern void m68040_fpu_op0(void); -extern void m68040_fpu_op1(void); -#endif /* M68K_EMULATE_040 */ +#include "m68kops.h" /* ======================================================================== */ /* ================================= DATA ================================= */ /* ======================================================================== */ -#if 0 -int m68ki_initial_cycles; -int m68ki_remaining_cycles = 0; /* Number of clocks remaining */ -#endif - -#if M68K_EMULATE_TRACE -uint m68ki_tracing = 0; -#endif /* M68K_EMULATE_TRACE */ - -#if M68K_EMULATE_FC -uint m68ki_address_space; -#endif /* M68K_EMULATE_FC */ - -#ifdef M68K_LOG_ENABLE -const char *const m68ki_cpu_names[] = -{ - "Invalid CPU", - "M68000", - "M68008", - "Invalid CPU", - "M68010", - "Invalid CPU", - "Invalid CPU", - "Invalid CPU", - "M68EC020", - "Invalid CPU", - "Invalid CPU", - "Invalid CPU", - "Invalid CPU", - "Invalid CPU", - "Invalid CPU", - "Invalid CPU", - "M68020" -}; -#endif /* M68K_LOG_ENABLE */ - -/* The CPU core */ -m68ki_cpu_core m68ki_cpu; - -#if M68K_EMULATE_ADDRESS_ERROR -#include -jmp_buf m68ki_aerr_trap; -int emulate_address_error = 0; -#endif /* M68K_EMULATE_ADDRESS_ERROR */ - -uint m68ki_aerr_address; -uint m68ki_aerr_write_mode; -uint m68ki_aerr_fc; - -/* Used by shift & rotate instructions */ -const uint8 m68ki_shift_8_table[65] = -{ - 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff -}; -const uint16 m68ki_shift_16_table[65] = -{ - 0x0000, 0x8000, 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, - 0xff80, 0xffc0, 0xffe0, 0xfff0, 0xfff8, 0xfffc, 0xfffe, 0xffff, 0xffff, - 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, - 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, - 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, - 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, - 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, - 0xffff, 0xffff -}; -const uint m68ki_shift_32_table[65] = -{ - 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, - 0xfc000000, 0xfe000000, 0xff000000, 0xff800000, 0xffc00000, 0xffe00000, - 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, 0xffff8000, - 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, - 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, - 0xfffffffc, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, - 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff -}; - - -/* Number of clock cycles to use for exception processing. - * I used 4 for any vectors that are undocumented for processing times. - */ -uint16 m68ki_exception_cycle_table[NUM_CPU_TYPES][256] = -{ - { /* 000 */ - 40, /* 0: Reset - Initial Stack Pointer */ - 4, /* 1: Reset - Initial Program Counter */ - 50, /* 2: Bus Error (unemulated) */ - 50, /* 3: Address Error (unemulated) */ - 34, /* 4: Illegal Instruction */ - 38, /* 5: Divide by Zero -- ASG: changed from 42 */ - 40, /* 6: CHK -- ASG: chanaged from 44 */ - 34, /* 7: TRAPV */ - 34, /* 8: Privilege Violation */ - 34, /* 9: Trace */ - 4, /* 10: 1010 */ - 4, /* 11: 1111 */ - 4, /* 12: RESERVED */ - 4, /* 13: Coprocessor Protocol Violation (unemulated) */ - 4, /* 14: Format Error */ - 44, /* 15: Uninitialized Interrupt */ - 4, /* 16: RESERVED */ - 4, /* 17: RESERVED */ - 4, /* 18: RESERVED */ - 4, /* 19: RESERVED */ - 4, /* 20: RESERVED */ - 4, /* 21: RESERVED */ - 4, /* 22: RESERVED */ - 4, /* 23: RESERVED */ - 44, /* 24: Spurious Interrupt */ - 44, /* 25: Level 1 Interrupt Autovector */ - 44, /* 26: Level 2 Interrupt Autovector */ - 44, /* 27: Level 3 Interrupt Autovector */ - 44, /* 28: Level 4 Interrupt Autovector */ - 44, /* 29: Level 5 Interrupt Autovector */ - 44, /* 30: Level 6 Interrupt Autovector */ - 44, /* 31: Level 7 Interrupt Autovector */ - 34, /* 32: TRAP #0 -- ASG: chanaged from 38 */ - 34, /* 33: TRAP #1 */ - 34, /* 34: TRAP #2 */ - 34, /* 35: TRAP #3 */ - 34, /* 36: TRAP #4 */ - 34, /* 37: TRAP #5 */ - 34, /* 38: TRAP #6 */ - 34, /* 39: TRAP #7 */ - 34, /* 40: TRAP #8 */ - 34, /* 41: TRAP #9 */ - 34, /* 42: TRAP #10 */ - 34, /* 43: TRAP #11 */ - 34, /* 44: TRAP #12 */ - 34, /* 45: TRAP #13 */ - 34, /* 46: TRAP #14 */ - 34, /* 47: TRAP #15 */ - 4, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ - 4, /* 49: FP Inexact Result (unemulated) */ - 4, /* 50: FP Divide by Zero (unemulated) */ - 4, /* 51: FP Underflow (unemulated) */ - 4, /* 52: FP Operand Error (unemulated) */ - 4, /* 53: FP Overflow (unemulated) */ - 4, /* 54: FP Signaling NAN (unemulated) */ - 4, /* 55: FP Unimplemented Data Type (unemulated) */ - 4, /* 56: MMU Configuration Error (unemulated) */ - 4, /* 57: MMU Illegal Operation Error (unemulated) */ - 4, /* 58: MMU Access Level Violation Error (unemulated) */ - 4, /* 59: RESERVED */ - 4, /* 60: RESERVED */ - 4, /* 61: RESERVED */ - 4, /* 62: RESERVED */ - 4, /* 63: RESERVED */ - /* 64-255: User Defined */ - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 - }, - -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - { /* 010 */ - 40, /* 0: Reset - Initial Stack Pointer */ - 4, /* 1: Reset - Initial Program Counter */ - 126, /* 2: Bus Error (unemulated) */ - 126, /* 3: Address Error (unemulated) */ - 38, /* 4: Illegal Instruction */ - 44, /* 5: Divide by Zero */ - 44, /* 6: CHK */ - 34, /* 7: TRAPV */ - 38, /* 8: Privilege Violation */ - 38, /* 9: Trace */ - 4, /* 10: 1010 */ - 4, /* 11: 1111 */ - 4, /* 12: RESERVED */ - 4, /* 13: Coprocessor Protocol Violation (unemulated) */ - 4, /* 14: Format Error */ - 44, /* 15: Uninitialized Interrupt */ - 4, /* 16: RESERVED */ - 4, /* 17: RESERVED */ - 4, /* 18: RESERVED */ - 4, /* 19: RESERVED */ - 4, /* 20: RESERVED */ - 4, /* 21: RESERVED */ - 4, /* 22: RESERVED */ - 4, /* 23: RESERVED */ - 46, /* 24: Spurious Interrupt */ - 46, /* 25: Level 1 Interrupt Autovector */ - 46, /* 26: Level 2 Interrupt Autovector */ - 46, /* 27: Level 3 Interrupt Autovector */ - 46, /* 28: Level 4 Interrupt Autovector */ - 46, /* 29: Level 5 Interrupt Autovector */ - 46, /* 30: Level 6 Interrupt Autovector */ - 46, /* 31: Level 7 Interrupt Autovector */ - 38, /* 32: TRAP #0 */ - 38, /* 33: TRAP #1 */ - 38, /* 34: TRAP #2 */ - 38, /* 35: TRAP #3 */ - 38, /* 36: TRAP #4 */ - 38, /* 37: TRAP #5 */ - 38, /* 38: TRAP #6 */ - 38, /* 39: TRAP #7 */ - 38, /* 40: TRAP #8 */ - 38, /* 41: TRAP #9 */ - 38, /* 42: TRAP #10 */ - 38, /* 43: TRAP #11 */ - 38, /* 44: TRAP #12 */ - 38, /* 45: TRAP #13 */ - 38, /* 46: TRAP #14 */ - 38, /* 47: TRAP #15 */ - 4, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ - 4, /* 49: FP Inexact Result (unemulated) */ - 4, /* 50: FP Divide by Zero (unemulated) */ - 4, /* 51: FP Underflow (unemulated) */ - 4, /* 52: FP Operand Error (unemulated) */ - 4, /* 53: FP Overflow (unemulated) */ - 4, /* 54: FP Signaling NAN (unemulated) */ - 4, /* 55: FP Unimplemented Data Type (unemulated) */ - 4, /* 56: MMU Configuration Error (unemulated) */ - 4, /* 57: MMU Illegal Operation Error (unemulated) */ - 4, /* 58: MMU Access Level Violation Error (unemulated) */ - 4, /* 59: RESERVED */ - 4, /* 60: RESERVED */ - 4, /* 61: RESERVED */ - 4, /* 62: RESERVED */ - 4, /* 63: RESERVED */ - /* 64-255: User Defined */ - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 - }, - { /* 020 */ - 4, /* 0: Reset - Initial Stack Pointer */ - 4, /* 1: Reset - Initial Program Counter */ - 50, /* 2: Bus Error (unemulated) */ - 50, /* 3: Address Error (unemulated) */ - 20, /* 4: Illegal Instruction */ - 38, /* 5: Divide by Zero */ - 40, /* 6: CHK */ - 20, /* 7: TRAPV */ - 34, /* 8: Privilege Violation */ - 25, /* 9: Trace */ - 20, /* 10: 1010 */ - 20, /* 11: 1111 */ - 4, /* 12: RESERVED */ - 4, /* 13: Coprocessor Protocol Violation (unemulated) */ - 4, /* 14: Format Error */ - 30, /* 15: Uninitialized Interrupt */ - 4, /* 16: RESERVED */ - 4, /* 17: RESERVED */ - 4, /* 18: RESERVED */ - 4, /* 19: RESERVED */ - 4, /* 20: RESERVED */ - 4, /* 21: RESERVED */ - 4, /* 22: RESERVED */ - 4, /* 23: RESERVED */ - 30, /* 24: Spurious Interrupt */ - 30, /* 25: Level 1 Interrupt Autovector */ - 30, /* 26: Level 2 Interrupt Autovector */ - 30, /* 27: Level 3 Interrupt Autovector */ - 30, /* 28: Level 4 Interrupt Autovector */ - 30, /* 29: Level 5 Interrupt Autovector */ - 30, /* 30: Level 6 Interrupt Autovector */ - 30, /* 31: Level 7 Interrupt Autovector */ - 20, /* 32: TRAP #0 */ - 20, /* 33: TRAP #1 */ - 20, /* 34: TRAP #2 */ - 20, /* 35: TRAP #3 */ - 20, /* 36: TRAP #4 */ - 20, /* 37: TRAP #5 */ - 20, /* 38: TRAP #6 */ - 20, /* 39: TRAP #7 */ - 20, /* 40: TRAP #8 */ - 20, /* 41: TRAP #9 */ - 20, /* 42: TRAP #10 */ - 20, /* 43: TRAP #11 */ - 20, /* 44: TRAP #12 */ - 20, /* 45: TRAP #13 */ - 20, /* 46: TRAP #14 */ - 20, /* 47: TRAP #15 */ - 4, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ - 4, /* 49: FP Inexact Result (unemulated) */ - 4, /* 50: FP Divide by Zero (unemulated) */ - 4, /* 51: FP Underflow (unemulated) */ - 4, /* 52: FP Operand Error (unemulated) */ - 4, /* 53: FP Overflow (unemulated) */ - 4, /* 54: FP Signaling NAN (unemulated) */ - 4, /* 55: FP Unimplemented Data Type (unemulated) */ - 4, /* 56: MMU Configuration Error (unemulated) */ - 4, /* 57: MMU Illegal Operation Error (unemulated) */ - 4, /* 58: MMU Access Level Violation Error (unemulated) */ - 4, /* 59: RESERVED */ - 4, /* 60: RESERVED */ - 4, /* 61: RESERVED */ - 4, /* 62: RESERVED */ - 4, /* 63: RESERVED */ - /* 64-255: User Defined */ - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 - }, - { /* 040 */ // TODO: these values are not correct - 4, /* 0: Reset - Initial Stack Pointer */ - 4, /* 1: Reset - Initial Program Counter */ - 50, /* 2: Bus Error (unemulated) */ - 50, /* 3: Address Error (unemulated) */ - 20, /* 4: Illegal Instruction */ - 38, /* 5: Divide by Zero */ - 40, /* 6: CHK */ - 20, /* 7: TRAPV */ - 34, /* 8: Privilege Violation */ - 25, /* 9: Trace */ - 20, /* 10: 1010 */ - 20, /* 11: 1111 */ - 4, /* 12: RESERVED */ - 4, /* 13: Coprocessor Protocol Violation (unemulated) */ - 4, /* 14: Format Error */ - 30, /* 15: Uninitialized Interrupt */ - 4, /* 16: RESERVED */ - 4, /* 17: RESERVED */ - 4, /* 18: RESERVED */ - 4, /* 19: RESERVED */ - 4, /* 20: RESERVED */ - 4, /* 21: RESERVED */ - 4, /* 22: RESERVED */ - 4, /* 23: RESERVED */ - 30, /* 24: Spurious Interrupt */ - 30, /* 25: Level 1 Interrupt Autovector */ - 30, /* 26: Level 2 Interrupt Autovector */ - 30, /* 27: Level 3 Interrupt Autovector */ - 30, /* 28: Level 4 Interrupt Autovector */ - 30, /* 29: Level 5 Interrupt Autovector */ - 30, /* 30: Level 6 Interrupt Autovector */ - 30, /* 31: Level 7 Interrupt Autovector */ - 20, /* 32: TRAP #0 */ - 20, /* 33: TRAP #1 */ - 20, /* 34: TRAP #2 */ - 20, /* 35: TRAP #3 */ - 20, /* 36: TRAP #4 */ - 20, /* 37: TRAP #5 */ - 20, /* 38: TRAP #6 */ - 20, /* 39: TRAP #7 */ - 20, /* 40: TRAP #8 */ - 20, /* 41: TRAP #9 */ - 20, /* 42: TRAP #10 */ - 20, /* 43: TRAP #11 */ - 20, /* 44: TRAP #12 */ - 20, /* 45: TRAP #13 */ - 20, /* 46: TRAP #14 */ - 20, /* 47: TRAP #15 */ - 4, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ - 4, /* 49: FP Inexact Result (unemulated) */ - 4, /* 50: FP Divide by Zero (unemulated) */ - 4, /* 51: FP Underflow (unemulated) */ - 4, /* 52: FP Operand Error (unemulated) */ - 4, /* 53: FP Overflow (unemulated) */ - 4, /* 54: FP Signaling NAN (unemulated) */ - 4, /* 55: FP Unimplemented Data Type (unemulated) */ - 4, /* 56: MMU Configuration Error (unemulated) */ - 4, /* 57: MMU Illegal Operation Error (unemulated) */ - 4, /* 58: MMU Access Level Violation Error (unemulated) */ - 4, /* 59: RESERVED */ - 4, /* 60: RESERVED */ - 4, /* 61: RESERVED */ - 4, /* 62: RESERVED */ - 4, /* 63: RESERVED */ - /* 64-255: User Defined */ - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4 - } -#endif -}; - -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -const uint8 m68ki_ea_idx_cycle_table[64] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* ..01.000 no memory indirect, base NULL */ - 5, /* ..01..01 memory indirect, base NULL, outer NULL */ - 7, /* ..01..10 memory indirect, base NULL, outer 16 */ - 7, /* ..01..11 memory indirect, base NULL, outer 32 */ - 0, 5, 7, 7, 0, 5, 7, 7, 0, 5, 7, 7, - 2, /* ..10.000 no memory indirect, base 16 */ - 7, /* ..10..01 memory indirect, base 16, outer NULL */ - 9, /* ..10..10 memory indirect, base 16, outer 16 */ - 9, /* ..10..11 memory indirect, base 16, outer 32 */ - 0, 7, 9, 9, 0, 7, 9, 9, 0, 7, 9, 9, - 6, /* ..11.000 no memory indirect, base 32 */ - 11, /* ..11..01 memory indirect, base 32, outer NULL */ - 13, /* ..11..10 memory indirect, base 32, outer 16 */ - 13, /* ..11..11 memory indirect, base 32, outer 32 */ - 0, 11, 13, 13, 0, 11, 13, 13, 0, 11, 13, 13 -}; -#endif - +static int irq_latency; /* ======================================================================== */ /* =============================== CALLBACKS ============================== */ @@ -464,61 +59,36 @@ const uint8 m68ki_ea_idx_cycle_table[64] = * callback is set to NULL */ +#if M68K_EMULATE_INT_ACK == OPT_ON /* Interrupt acknowledge */ -static int default_int_ack_callback_data; static int default_int_ack_callback(int int_level) { - default_int_ack_callback_data = int_level; CPU_INT_LEVEL = 0; return M68K_INT_ACK_AUTOVECTOR; } +#endif -/* Breakpoint acknowledge */ -static unsigned int default_bkpt_ack_callback_data; -static void default_bkpt_ack_callback(unsigned int data) -{ - default_bkpt_ack_callback_data = data; -} - +#if M68K_EMULATE_RESET == OPT_ON /* Called when a reset instruction is executed */ static void default_reset_instr_callback(void) { } +#endif -/* Called when a cmpi.l #v, dn instruction is executed */ -static void default_cmpild_instr_callback(unsigned int val, int reg) -{ -} - -/* Called when a rte instruction is executed */ -static void default_rte_instr_callback(void) -{ -} - +#if M68K_TAS_HAS_CALLBACK == OPT_ON /* Called when a tas instruction is executed */ static int default_tas_instr_callback(void) { return 1; // allow writeback } +#endif -/* Called when the program counter changed by a large value */ -static unsigned int default_pc_changed_callback_data; -static void default_pc_changed_callback(unsigned int new_pc) -{ - default_pc_changed_callback_data = new_pc; -} - +#if M68K_EMULATE_FC == OPT_ON /* Called every time there's bus activity (read/write to/from memory */ -static unsigned int default_set_fc_callback_data; static void default_set_fc_callback(unsigned int new_fc) -{ - default_set_fc_callback_data = new_fc; -} - -/* Called every instruction cycle prior to execution */ -static void default_instr_hook_callback(unsigned int pc) { } +#endif /* ======================================================================== */ @@ -526,66 +96,45 @@ static void default_instr_hook_callback(unsigned int pc) /* ======================================================================== */ /* Access the internals of the CPU */ -unsigned int m68k_get_reg(void* context, m68k_register_t regnum) +unsigned int m68k_get_reg(m68k_register_t regnum) { - m68ki_cpu_core* cpu = context != NULL ?(m68ki_cpu_core*)context : &m68ki_cpu; - switch(regnum) { - case M68K_REG_D0: return cpu->dar[0]; - case M68K_REG_D1: return cpu->dar[1]; - case M68K_REG_D2: return cpu->dar[2]; - case M68K_REG_D3: return cpu->dar[3]; - case M68K_REG_D4: return cpu->dar[4]; - case M68K_REG_D5: return cpu->dar[5]; - case M68K_REG_D6: return cpu->dar[6]; - case M68K_REG_D7: return cpu->dar[7]; - case M68K_REG_A0: return cpu->dar[8]; - case M68K_REG_A1: return cpu->dar[9]; - case M68K_REG_A2: return cpu->dar[10]; - case M68K_REG_A3: return cpu->dar[11]; - case M68K_REG_A4: return cpu->dar[12]; - case M68K_REG_A5: return cpu->dar[13]; - case M68K_REG_A6: return cpu->dar[14]; - case M68K_REG_A7: return cpu->dar[15]; - case M68K_REG_PC: return MASK_OUT_ABOVE_32(cpu->pc); - case M68K_REG_SR: return cpu->t1_flag | - cpu->t0_flag | - (cpu->s_flag << 11) | - (cpu->m_flag << 11) | - cpu->int_mask | - ((cpu->x_flag & XFLAG_SET) >> 4) | - ((cpu->n_flag & NFLAG_SET) >> 4) | - ((!cpu->not_z_flag) << 2) | - ((cpu->v_flag & VFLAG_SET) >> 6) | - ((cpu->c_flag & CFLAG_SET) >> 8); - case M68K_REG_SP: return cpu->dar[15]; - case M68K_REG_USP: return cpu->s_flag ? cpu->sp[0] : cpu->dar[15]; - case M68K_REG_ISP: return cpu->s_flag && !cpu->m_flag ? cpu->dar[15] : cpu->sp[4]; - case M68K_REG_MSP: return cpu->s_flag && cpu->m_flag ? cpu->dar[15] : cpu->sp[6]; - case M68K_REG_SFC: return cpu->sfc; - case M68K_REG_DFC: return cpu->dfc; - case M68K_REG_VBR: return cpu->vbr; - case M68K_REG_CACR: return cpu->cacr; - case M68K_REG_CAAR: return cpu->caar; - case M68K_REG_PREF_ADDR: return cpu->pref_addr; - case M68K_REG_PREF_DATA: return cpu->pref_data; - case M68K_REG_PPC: return MASK_OUT_ABOVE_32(cpu->ppc); - case M68K_REG_IR: return cpu->ir; - case M68K_REG_CPU_TYPE: - switch(cpu->cpu_type) - { - case CPU_TYPE_000: return (unsigned int)M68K_CPU_TYPE_68000; - case CPU_TYPE_008: return (unsigned int)M68K_CPU_TYPE_68008; - case CPU_TYPE_010: return (unsigned int)M68K_CPU_TYPE_68010; - case CPU_TYPE_EC020: return (unsigned int)M68K_CPU_TYPE_68EC020; - case CPU_TYPE_020: return (unsigned int)M68K_CPU_TYPE_68020; - case CPU_TYPE_040: return (unsigned int)M68K_CPU_TYPE_68040; - } - return M68K_CPU_TYPE_INVALID; + case M68K_REG_D0: return m68ki_cpu.dar[0]; + case M68K_REG_D1: return m68ki_cpu.dar[1]; + case M68K_REG_D2: return m68ki_cpu.dar[2]; + case M68K_REG_D3: return m68ki_cpu.dar[3]; + case M68K_REG_D4: return m68ki_cpu.dar[4]; + case M68K_REG_D5: return m68ki_cpu.dar[5]; + case M68K_REG_D6: return m68ki_cpu.dar[6]; + case M68K_REG_D7: return m68ki_cpu.dar[7]; + case M68K_REG_A0: return m68ki_cpu.dar[8]; + case M68K_REG_A1: return m68ki_cpu.dar[9]; + case M68K_REG_A2: return m68ki_cpu.dar[10]; + case M68K_REG_A3: return m68ki_cpu.dar[11]; + case M68K_REG_A4: return m68ki_cpu.dar[12]; + case M68K_REG_A5: return m68ki_cpu.dar[13]; + case M68K_REG_A6: return m68ki_cpu.dar[14]; + case M68K_REG_A7: return m68ki_cpu.dar[15]; + case M68K_REG_PC: return MASK_OUT_ABOVE_32(m68ki_cpu.pc); + case M68K_REG_SR: return m68ki_cpu.t1_flag | + (m68ki_cpu.s_flag << 11) | + m68ki_cpu.int_mask | + ((m68ki_cpu.x_flag & XFLAG_SET) >> 4) | + ((m68ki_cpu.n_flag & NFLAG_SET) >> 4) | + ((!m68ki_cpu.not_z_flag) << 2) | + ((m68ki_cpu.v_flag & VFLAG_SET) >> 6) | + ((m68ki_cpu.c_flag & CFLAG_SET) >> 8); + case M68K_REG_SP: return m68ki_cpu.dar[15]; + case M68K_REG_USP: return m68ki_cpu.s_flag ? m68ki_cpu.sp[0] : m68ki_cpu.dar[15]; + case M68K_REG_ISP: return m68ki_cpu.s_flag ? m68ki_cpu.dar[15] : m68ki_cpu.sp[4]; +#if M68K_EMULATE_PREFETCH + case M68K_REG_PREF_ADDR: return m68ki_cpu.pref_addr; + case M68K_REG_PREF_DATA: return m68ki_cpu.pref_data; +#endif + case M68K_REG_IR: return m68ki_cpu.ir; default: return 0; } - return 0; } void m68k_set_reg(m68k_register_t regnum, unsigned int value) @@ -616,307 +165,155 @@ void m68k_set_reg(m68k_register_t regnum, unsigned int value) else REG_SP = MASK_OUT_ABOVE_32(value); return; - case M68K_REG_ISP: if(FLAG_S && !FLAG_M) + case M68K_REG_ISP: if(FLAG_S) REG_SP = MASK_OUT_ABOVE_32(value); else REG_ISP = MASK_OUT_ABOVE_32(value); return; - case M68K_REG_MSP: if(FLAG_S && FLAG_M) - REG_SP = MASK_OUT_ABOVE_32(value); - else - REG_MSP = MASK_OUT_ABOVE_32(value); - return; - case M68K_REG_VBR: REG_VBR = MASK_OUT_ABOVE_32(value); return; - case M68K_REG_SFC: REG_SFC = value & 7; return; - case M68K_REG_DFC: REG_DFC = value & 7; return; - case M68K_REG_CACR: REG_CACR = MASK_OUT_ABOVE_32(value); return; - case M68K_REG_CAAR: REG_CAAR = MASK_OUT_ABOVE_32(value); return; - case M68K_REG_PPC: REG_PPC = MASK_OUT_ABOVE_32(value); return; case M68K_REG_IR: REG_IR = MASK_OUT_ABOVE_16(value); return; +#if M68K_EMULATE_PREFETCH case M68K_REG_PREF_ADDR: CPU_PREF_ADDR = MASK_OUT_ABOVE_32(value); return; - case M68K_REG_CPU_TYPE: m68k_set_cpu_type(value); return; +#endif default: return; } } /* Set the callbacks */ +#if M68K_EMULATE_INT_ACK == OPT_ON void m68k_set_int_ack_callback(int (*callback)(int int_level)) { CALLBACK_INT_ACK = callback ? callback : default_int_ack_callback; } +#endif -void m68k_set_bkpt_ack_callback(void (*callback)(unsigned int data)) -{ - CALLBACK_BKPT_ACK = callback ? callback : default_bkpt_ack_callback; -} - +#if M68K_EMULATE_RESET == OPT_ON void m68k_set_reset_instr_callback(void (*callback)(void)) { CALLBACK_RESET_INSTR = callback ? callback : default_reset_instr_callback; } +#endif -void m68k_set_cmpild_instr_callback(void (*callback)(unsigned int, int)) -{ - CALLBACK_CMPILD_INSTR = callback ? callback : default_cmpild_instr_callback; -} - -void m68k_set_rte_instr_callback(void (*callback)(void)) -{ - CALLBACK_RTE_INSTR = callback ? callback : default_rte_instr_callback; -} - +#if M68K_TAS_HAS_CALLBACK == OPT_ON void m68k_set_tas_instr_callback(int (*callback)(void)) { CALLBACK_TAS_INSTR = callback ? callback : default_tas_instr_callback; } +#endif -void m68k_set_pc_changed_callback(void (*callback)(unsigned int new_pc)) -{ - CALLBACK_PC_CHANGED = callback ? callback : default_pc_changed_callback; -} - +#if M68K_EMULATE_FC == OPT_ON void m68k_set_fc_callback(void (*callback)(unsigned int new_fc)) { CALLBACK_SET_FC = callback ? callback : default_set_fc_callback; } - -void m68k_set_instr_hook_callback(void (*callback)(unsigned int pc)) -{ - CALLBACK_INSTR_HOOK = callback ? callback : default_instr_hook_callback; -} - -#include -/* Set the CPU type. */ -void m68k_set_cpu_type(unsigned int cpu_type) -{ - switch(cpu_type) - { - case M68K_CPU_TYPE_68000: - CPU_TYPE = CPU_TYPE_000; - CPU_ADDRESS_MASK = 0x00ffffff; - CPU_SR_MASK = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ - CYC_INSTRUCTION = m68ki_cycles[0]; - CYC_EXCEPTION = m68ki_exception_cycle_table[0]; - CYC_BCC_NOTAKE_B = -2 * 7; - CYC_BCC_NOTAKE_W = 2 * 7; - CYC_DBCC_F_NOEXP = -2 * 7; - CYC_DBCC_F_EXP = 2 * 7; - CYC_SCC_R_TRUE = 2 * 7; - CYC_MOVEM_W = 4 * 7; - CYC_MOVEM_L = 8 * 7; - CYC_SHIFT = 2 * 7; - CYC_RESET = 132 * 7; - return; - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - case M68K_CPU_TYPE_68008: - CPU_TYPE = CPU_TYPE_008; - CPU_ADDRESS_MASK = 0x003fffff; - CPU_SR_MASK = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ - CYC_INSTRUCTION = m68ki_cycles[0]; - CYC_EXCEPTION = m68ki_exception_cycle_table[0]; - CYC_BCC_NOTAKE_B = -2; - CYC_BCC_NOTAKE_W = 2; - CYC_DBCC_F_NOEXP = -2; - CYC_DBCC_F_EXP = 2; - CYC_SCC_R_TRUE = 2; - CYC_MOVEM_W = 2; - CYC_MOVEM_L = 3; - CYC_SHIFT = 1; - CYC_RESET = 132; - return; - case M68K_CPU_TYPE_68010: - CPU_TYPE = CPU_TYPE_010; - CPU_ADDRESS_MASK = 0x00ffffff; - CPU_SR_MASK = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */ - CYC_INSTRUCTION = m68ki_cycles[1]; - CYC_EXCEPTION = m68ki_exception_cycle_table[1]; - CYC_BCC_NOTAKE_B = -4; - CYC_BCC_NOTAKE_W = 0; - CYC_DBCC_F_NOEXP = 0; - CYC_DBCC_F_EXP = 6; - CYC_SCC_R_TRUE = 0; - CYC_MOVEM_W = 2; - CYC_MOVEM_L = 3; - CYC_SHIFT = 1; - CYC_RESET = 130; - return; - case M68K_CPU_TYPE_68EC020: - CPU_TYPE = CPU_TYPE_EC020; - CPU_ADDRESS_MASK = 0x00ffffff; - CPU_SR_MASK = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ - CYC_INSTRUCTION = m68ki_cycles[2]; - CYC_EXCEPTION = m68ki_exception_cycle_table[2]; - CYC_BCC_NOTAKE_B = -2; - CYC_BCC_NOTAKE_W = 0; - CYC_DBCC_F_NOEXP = 0; - CYC_DBCC_F_EXP = 4; - CYC_SCC_R_TRUE = 0; - CYC_MOVEM_W = 2; - CYC_MOVEM_L = 2; - CYC_SHIFT = 0; - CYC_RESET = 518; - return; - case M68K_CPU_TYPE_68020: - CPU_TYPE = CPU_TYPE_020; - CPU_ADDRESS_MASK = 0xffffffff; - CPU_SR_MASK = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ - CYC_INSTRUCTION = m68ki_cycles[2]; - CYC_EXCEPTION = m68ki_exception_cycle_table[2]; - CYC_BCC_NOTAKE_B = -2; - CYC_BCC_NOTAKE_W = 0; - CYC_DBCC_F_NOEXP = 0; - CYC_DBCC_F_EXP = 4; - CYC_SCC_R_TRUE = 0; - CYC_MOVEM_W = 2; - CYC_MOVEM_L = 2; - CYC_SHIFT = 0; - CYC_RESET = 518; - return; - case M68K_CPU_TYPE_68040: // TODO: these values are not correct - CPU_TYPE = CPU_TYPE_040; - CPU_ADDRESS_MASK = 0xffffffff; - CPU_SR_MASK = 0xf71f; /* T1 T0 S M -- I2 I1 I0 -- -- -- X N Z V C */ - CYC_INSTRUCTION = m68ki_cycles[2]; - CYC_EXCEPTION = m68ki_exception_cycle_table[2]; - CYC_BCC_NOTAKE_B = -2; - CYC_BCC_NOTAKE_W = 0; - CYC_DBCC_F_NOEXP = 0; - CYC_DBCC_F_EXP = 4; - CYC_SCC_R_TRUE = 0; - CYC_MOVEM_W = 2; - CYC_MOVEM_L = 2; - CYC_SHIFT = 0; - CYC_RESET = 518; - return; #endif - } -} -#if 0 -/* Execute a single instruction */ -INLINE int m68k_execute(void) -{ - /* Set our pool of clock cycles available */ - SET_CYCLES(0); - - /* Set tracing accodring to T1. (T0 is done inside instruction) */ - m68ki_trace_t1(); /* auto-disable (see m68kcpu.h) */ - - /* Set the address space for reads */ - m68ki_use_data_space(); /* auto-disable (see m68kcpu.h) */ - - /* Call external hook to peek at CPU */ - m68ki_instr_hook(REG_PC); /* auto-disable (see m68kcpu.h) */ - - /* Record previous program counter */ - REG_PPC = REG_PC; - - /* Read an instruction and call its handler */ - REG_IR = m68ki_read_imm_16(); - m68ki_instruction_jump_table[REG_IR](); - USE_CYCLES(CYC_INSTRUCTION[REG_IR]); - - /* Trace m68k_exception, if necessary */ - m68ki_exception_if_trace(); /* auto-disable (see m68kcpu.h) */ - - /* return how many clocks we used */ - return GET_CYCLES(); -} +#ifdef LOGVDP +extern void error(char *format, ...); +extern uint16 v_counter; #endif /* ASG: rewrote so that the int_level is a mask of the IPL0/IPL1/IPL2 bits */ /* KS: Modified so that IPL* bits match with mask positions in the SR * and cleaned out remenants of the interrupt controller. */ +void m68k_update_irq(unsigned int mask) +{ + /* Update IRQ level */ + CPU_INT_LEVEL |= (mask << 8); + +#ifdef LOGVDP + error("[%d(%d)][%d(%d)] IRQ Level = %d(0x%02x) (%x)\n", v_counter, mcycles_68k/3420, mcycles_68k, mcycles_68k%3420,CPU_INT_LEVEL>>8,FLAG_INT_MASK,m68k_get_reg(M68K_REG_PC)); +#endif + + /* Check interrupt mask to process IRQ */ + m68ki_check_interrupts(); +} + void m68k_set_irq(unsigned int int_level) { - uint old_level = CPU_INT_LEVEL; + /* Set IRQ level */ CPU_INT_LEVEL = int_level << 8; + +#ifdef LOGVDP + error("[%d(%d)][%d(%d)] IRQ Level = %d(0x%02x) (%x)\n", v_counter, mcycles_68k/3420, mcycles_68k, mcycles_68k%3420,CPU_INT_LEVEL>>8,FLAG_INT_MASK,m68k_get_reg(M68K_REG_PC)); +#endif - /* A transition from < 7 to 7 always interrupts (NMI) */ - /* Note: Level 7 can also level trigger like a normal IRQ */ - if(old_level != 0x0700 && CPU_INT_LEVEL == 0x0700) - m68ki_exception_interrupt(7); /* Edge triggered level 7 (NMI) */ - else - m68ki_check_interrupts(); /* Level triggered (IRQ) */ + /* Check interrupt mask to process IRQ */ + m68ki_check_interrupts(); } -#ifdef LOGVDP -extern uint16 v_counter; -extern void error(char *format, ...); -#endif -extern uint8 m68k_irq_state; - -void m68k_run (unsigned int cycles) +/* IRQ latency (Fatal Rewind, Sesame's Street Counting Cafe)*/ +void m68k_set_irq_delay(unsigned int int_level) { - /* Return point if we had an address error */ - m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */ + /* Prevent reentrance */ + if (!irq_latency) + { + /* This is always triggered from MOVE instructions (VDP CTRL port write) */ + /* We just make sure this is not a MOVE.L instruction as we could be in */ + /* the middle of its execution (first memory write). */ + if ((REG_IR & 0xF000) != 0x2000) + { + /* Finish executing current instruction */ + USE_CYCLES(CYC_INSTRUCTION[REG_IR]); + /* One instruction delay before interrupt */ + irq_latency = 1; + m68ki_trace_t1() /* auto-disable (see m68kcpu.h) */ + m68ki_use_data_space() /* auto-disable (see m68kcpu.h) */ + REG_IR = m68ki_read_imm_16(); + m68ki_instruction_jump_table[REG_IR](); + m68ki_exception_if_trace() /* auto-disable (see m68kcpu.h) */ + irq_latency = 0; + } + + /* Set IRQ level */ + CPU_INT_LEVEL = int_level << 8; + } + +#ifdef LOGVDP + error("[%d(%d)][%d(%d)] IRQ Level = %d(0x%02x) (%x)\n", v_counter, mcycles_68k/3420, mcycles_68k, mcycles_68k%3420,CPU_INT_LEVEL>>8,FLAG_INT_MASK,m68k_get_reg(M68K_REG_PC)); +#endif + + /* Check interrupt mask to process IRQ */ + m68ki_check_interrupts(); /* Level triggered (IRQ) */ +} + + +void m68k_run(unsigned int cycles) +{ + /* Make sure we're not stopped */ + if (CPU_STOPPED) + { + mcycles_68k = cycles; + return; + } + + /* Return point for when we have an address error (TODO: use goto) */ + m68ki_set_address_error_trap() /* auto-disable (see m68kcpu.h) */ + + /* Save end cycles count for when CPU is stopped */ + end_cycles = cycles; + while (mcycles_68k < cycles) { - /* check IRQ triggering */ - if (m68k_irq_state & 0x10) - { - m68k_irq_state &= ~0x10; - CPU_INT_LEVEL = (m68k_irq_state & 6) << 8; + /* Set tracing accodring to T1. */ + m68ki_trace_t1() /* auto-disable (see m68kcpu.h) */ - /* IRQ was triggered during previous instruction */ - if (m68k_irq_state & 0x20) - { - /* one instruction latency */ - REG_IR = m68ki_read_imm_16(); - m68ki_instruction_jump_table[REG_IR](); - USE_CYCLES(CYC_INSTRUCTION[REG_IR]); - } -#ifdef LOGVDP - error("[%d(%d)][%d(%d)] IRQ Level = %d(0x%02x) (%x)\n", v_counter, mcycles_68k/3420, mcycles_68k, mcycles_68k%3420,CPU_INT_LEVEL>>8,FLAG_INT_MASK,m68k_get_reg (NULL, M68K_REG_PC)); -#endif - /* update internal interrupt level */ - m68ki_check_interrupts(); + /* Set the address space for reads */ + m68ki_use_data_space() /* auto-disable (see m68kcpu.h) */ - if (mcycles_68k >= cycles) return; - } - - /* Make sure we're not stopped */ - if(CPU_STOPPED) - { - mcycles_68k = cycles; - return; - } - - /* execute a single instruction */ + /* Decode next instruction */ REG_IR = m68ki_read_imm_16(); - m68ki_instruction_jump_table[REG_IR](); - USE_CYCLES(CYC_INSTRUCTION[REG_IR]); + + /* Execute instruction */ + m68ki_instruction_jump_table[REG_IR](); /* TODO: use labels table with goto */ + USE_CYCLES(CYC_INSTRUCTION[REG_IR]); /* TODO: move into instruction handlers */ + + /* Trace m68k_exception, if necessary */ + m68ki_exception_if_trace(); /* auto-disable (see m68kcpu.h) */ } } -#if 0 -int m68k_cycles_run(void) -{ - return m68ki_initial_cycles - GET_CYCLES(); -} - -int m68k_cycles_remaining(void) -{ - return GET_CYCLES(); -} - -/* Change the timeslice */ -void m68k_modify_timeslice(int cycles) -{ - m68ki_initial_cycles += cycles; - ADD_CYCLES(cycles); -} - -void m68k_end_timeslice(void) -{ - m68ki_initial_cycles = GET_CYCLES(); - SET_CYCLES(0); -} -#endif - void m68k_init(void) { static uint emulation_initialized = 0; @@ -928,15 +325,18 @@ void m68k_init(void) emulation_initialized = 1; } +#if M68K_EMULATE_INT_ACK == OPT_ON m68k_set_int_ack_callback(NULL); - m68k_set_bkpt_ack_callback(NULL); +#endif +#if M68K_EMULATE_RESET == OPT_ON m68k_set_reset_instr_callback(NULL); - m68k_set_cmpild_instr_callback(NULL); - m68k_set_rte_instr_callback(NULL); +#endif +#if M68K_TAS_HAS_CALLBACK == OPT_ON m68k_set_tas_instr_callback(NULL); - m68k_set_pc_changed_callback(NULL); +#endif +#if M68K_EMULATE_FC == OPT_ON m68k_set_fc_callback(NULL); - m68k_set_instr_hook_callback(NULL); +#endif } /* Pulse the RESET line on the CPU */ @@ -944,21 +344,21 @@ void m68k_pulse_reset(void) { /* Clear all stop levels and eat up all remaining cycles */ CPU_STOPPED = 0; -#if 0 - SET_CYCLES(0); -#endif +#if M68K_EMULATE_ADDRESS_ERROR CPU_RUN_MODE = RUN_MODE_BERR_AERR_RESET; +#endif /* Turn off tracing */ - FLAG_T1 = FLAG_T0 = 0; - m68ki_clear_trace(); + FLAG_T1 = 0; + m68ki_clear_trace() + /* Interrupt mask to level 7 */ FLAG_INT_MASK = 0x0700; CPU_INT_LEVEL = 0; - /* Reset VBR */ - REG_VBR = 0; + irq_latency = 0; + /* Go to supervisor mode */ - m68ki_set_sm_flag(SFLAG_SET | MFLAG_CLEAR); + m68ki_set_s_flag(SFLAG_SET); /* Invalidate the prefetch queue */ #if M68K_EMULATE_PREFETCH @@ -972,7 +372,9 @@ void m68k_pulse_reset(void) REG_PC = m68ki_read_imm_32(); m68ki_jump(REG_PC); +#if M68K_EMULATE_ADDRESS_ERROR CPU_RUN_MODE = RUN_MODE_NORMAL; +#endif USE_CYCLES(CYC_EXCEPTION[EXCEPTION_RESET]); } @@ -984,79 +386,6 @@ void m68k_pulse_halt(void) } -/* Get and set the current CPU context */ -/* This is to allow for multiple CPUs */ -unsigned int m68k_context_size() -{ - return sizeof(m68ki_cpu_core); -} - -unsigned int m68k_get_context(void* dst) -{ - if(dst) *(m68ki_cpu_core*)dst = m68ki_cpu; - return sizeof(m68ki_cpu_core); -} - -void m68k_set_context(void* src) -{ - if(src) m68ki_cpu = *(m68ki_cpu_core*)src; -} - - - -/* ======================================================================== */ -/* ============================== MAME STUFF ============================== */ -/* ======================================================================== */ - -#if M68K_COMPILE_FOR_MAME == OPT_ON - -static struct { - uint16 sr; - uint8 stopped; - uint8 halted; -} m68k_substate; - -static void m68k_prepare_substate(void) -{ - m68k_substate.sr = m68ki_get_sr(); - m68k_substate.stopped = (CPU_STOPPED & STOP_LEVEL_STOP) != 0; - m68k_substate.halted = (CPU_STOPPED & STOP_LEVEL_HALT) != 0; -} - -static void m68k_post_load(void) -{ - m68ki_set_sr_noint_nosp(m68k_substate.sr); - CPU_STOPPED = m68k_substate.stopped ? STOP_LEVEL_STOP : 0 - | m68k_substate.halted ? STOP_LEVEL_HALT : 0; - m68ki_jump(REG_PC); -} - -void m68k_state_register(const char *type, int index) -{ - /* Note, D covers A because the dar array is common, REG_A=REG_D+8 */ - state_save_register_item_array(type, index, REG_D); - state_save_register_item(type, index, REG_PPC); - state_save_register_item(type, index, REG_PC); - state_save_register_item(type, index, REG_USP); - state_save_register_item(type, index, REG_ISP); - state_save_register_item(type, index, REG_MSP); - state_save_register_item(type, index, REG_VBR); - state_save_register_item(type, index, REG_SFC); - state_save_register_item(type, index, REG_DFC); - state_save_register_item(type, index, REG_CACR); - state_save_register_item(type, index, REG_CAAR); - state_save_register_item(type, index, m68k_substate.sr); - state_save_register_item(type, index, CPU_INT_LEVEL); - state_save_register_item(type, index, m68k_substate.stopped); - state_save_register_item(type, index, m68k_substate.halted); - state_save_register_item(type, index, CPU_PREF_ADDR); - state_save_register_item(type, index, CPU_PREF_DATA); - state_save_register_func_presave(m68k_prepare_substate); - state_save_register_func_postload(m68k_post_load); -} - -#endif /* M68K_COMPILE_FOR_MAME */ - /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */ diff --git a/source/m68k/m68kcpu.h b/source/m68k/m68kcpu.h index 5b1df54..e9cf430 100644 --- a/source/m68k/m68kcpu.h +++ b/source/m68k/m68kcpu.h @@ -1,4 +1,3 @@ -#include /* ======================================================================== */ /* ========================= LICENSING & COPYRIGHT ======================== */ /* ======================================================================== */ @@ -20,14 +19,24 @@ * http://kstenerud.cjb.net */ + /* Modified by Eke-Eke for Genesis Plus GX: - + - removed unused stuff to reduce memory usage / optimize execution (multiple CPU types support, NMI support, ...) + - moved stuff to compile statically in a single object file + - implemented support for global cycle count (shared by 68k & Z80 CPU) + - added support for interrupt latency (Sesame's Street Counting Cafe, Fatal Rewind) + - added proper cycle use on reset + - added cycle accurate timings for MUL/DIV instructions (thanks to Jorge Cwik !) + - fixed undocumented flags for DIV instructions (Blood Shot) + + */ #ifndef M68KCPU__HEADER #define M68KCPU__HEADER -#include "m68k.h" +#include #include +#include "m68k.h" #if M68K_EMULATE_ADDRESS_ERROR #include @@ -154,19 +163,12 @@ #define FUNCTION_CODE_SUPERVISOR_PROGRAM 6 #define FUNCTION_CODE_CPU_SPACE 7 -/* CPU types for deciding what to emulate */ -#define CPU_TYPE_000 1 -#define CPU_TYPE_008 2 -#define CPU_TYPE_010 4 -#define CPU_TYPE_EC020 8 -#define CPU_TYPE_020 16 -#define CPU_TYPE_040 32 - /* Different ways to stop the CPU */ #define STOP_LEVEL_STOP 1 #define STOP_LEVEL_HALT 2 /* Used for 68000 address error processing */ +#if M68K_EMULATE_ADDRESS_ERROR #define INSTRUCTION_YES 0 #define INSTRUCTION_NO 0x08 #define MODE_READ 0x10 @@ -174,6 +176,7 @@ #define RUN_MODE_NORMAL 0 #define RUN_MODE_BERR_AERR_RESET 1 +#endif #ifndef NULL #define NULL ((void*)0) @@ -298,34 +301,18 @@ /* ------------------------------ CPU Access ------------------------------ */ /* Access the CPU registers */ -#define CPU_TYPE m68ki_cpu.cpu_type - #define REG_DA m68ki_cpu.dar /* easy access to data and address regs */ #define REG_D m68ki_cpu.dar #define REG_A (m68ki_cpu.dar+8) -#define REG_PPC m68ki_cpu.ppc #define REG_PC m68ki_cpu.pc #define REG_SP_BASE m68ki_cpu.sp #define REG_USP m68ki_cpu.sp[0] #define REG_ISP m68ki_cpu.sp[4] -#define REG_MSP m68ki_cpu.sp[6] #define REG_SP m68ki_cpu.dar[15] -#define REG_VBR m68ki_cpu.vbr -#define REG_SFC m68ki_cpu.sfc -#define REG_DFC m68ki_cpu.dfc -#define REG_CACR m68ki_cpu.cacr -#define REG_CAAR m68ki_cpu.caar #define REG_IR m68ki_cpu.ir -#define REG_FP m68ki_cpu.fpr -#define REG_FPCR m68ki_cpu.fpcr -#define REG_FPSR m68ki_cpu.fpsr -#define REG_FPIAR m68ki_cpu.fpiar - #define FLAG_T1 m68ki_cpu.t1_flag -#define FLAG_T0 m68ki_cpu.t0_flag #define FLAG_S m68ki_cpu.s_flag -#define FLAG_M m68ki_cpu.m_flag #define FLAG_X m68ki_cpu.x_flag #define FLAG_N m68ki_cpu.n_flag #define FLAG_Z m68ki_cpu.not_z_flag @@ -335,152 +322,68 @@ #define CPU_INT_LEVEL m68ki_cpu.int_level /* ASG: changed from CPU_INTS_PENDING */ #define CPU_STOPPED m68ki_cpu.stopped +#if M68K_EMULATE_PREFETCH #define CPU_PREF_ADDR m68ki_cpu.pref_addr #define CPU_PREF_DATA m68ki_cpu.pref_data -#define CPU_ADDRESS_MASK m68ki_cpu.address_mask -#define CPU_SR_MASK m68ki_cpu.sr_mask +#endif +#define CPU_ADDRESS_MASK 0x00ffffff +#if M68K_EMULATE_ADDRESS_ERROR #define CPU_INSTR_MODE m68ki_cpu.instr_mode #define CPU_RUN_MODE m68ki_cpu.run_mode +#endif -#define CYC_INSTRUCTION m68ki_cpu.cyc_instruction -#define CYC_EXCEPTION m68ki_cpu.cyc_exception -#define CYC_BCC_NOTAKE_B m68ki_cpu.cyc_bcc_notake_b -#define CYC_BCC_NOTAKE_W m68ki_cpu.cyc_bcc_notake_w -#define CYC_DBCC_F_NOEXP m68ki_cpu.cyc_dbcc_f_noexp -#define CYC_DBCC_F_EXP m68ki_cpu.cyc_dbcc_f_exp -#define CYC_SCC_R_TRUE m68ki_cpu.cyc_scc_r_true -#define CYC_MOVEM_W m68ki_cpu.cyc_movem_w -#define CYC_MOVEM_L m68ki_cpu.cyc_movem_l -#define CYC_SHIFT m68ki_cpu.cyc_shift -#define CYC_RESET m68ki_cpu.cyc_reset - +#define CYC_INSTRUCTION m68ki_cycles +#define CYC_EXCEPTION m68ki_exception_cycle_table +#define CYC_BCC_NOTAKE_B ( -2 * 7) +#define CYC_BCC_NOTAKE_W ( 2 * 7) +#define CYC_DBCC_F_NOEXP ( -2 * 7) +#define CYC_DBCC_F_EXP ( 2 * 7) +#define CYC_SCC_R_TRUE ( 2 * 7) +#define CYC_MOVEM_W ( 4 * 7) +#define CYC_MOVEM_L ( 8 * 7) +#define CYC_SHIFT ( 2 * 7) +#define CYC_RESET (132 * 7) +#if M68K_EMULATE_INT_ACK == OPT_ON #define CALLBACK_INT_ACK m68ki_cpu.int_ack_callback -#define CALLBACK_BKPT_ACK m68ki_cpu.bkpt_ack_callback +#endif +#if M68K_EMULATE_RESET == OPT_ON #define CALLBACK_RESET_INSTR m68ki_cpu.reset_instr_callback -#define CALLBACK_CMPILD_INSTR m68ki_cpu.cmpild_instr_callback -#define CALLBACK_RTE_INSTR m68ki_cpu.rte_instr_callback +#endif +#if M68K_TAS_HAS_CALLBACK == OPT_ON #define CALLBACK_TAS_INSTR m68ki_cpu.tas_instr_callback -#define CALLBACK_PC_CHANGED m68ki_cpu.pc_changed_callback +#endif +#if M68K_EMULATE_FC == OPT_ON #define CALLBACK_SET_FC m68ki_cpu.set_fc_callback -#define CALLBACK_INSTR_HOOK m68ki_cpu.instr_hook_callback - +#endif /* ----------------------------- Configuration ---------------------------- */ /* These defines are dependant on the configuration defines in m68kconf.h */ -/* Disable certain comparisons if we're not using all CPU types */ -#if M68K_EMULATE_040 - #define CPU_TYPE_IS_040_PLUS(A) ((A) & CPU_TYPE_040) - #define CPU_TYPE_IS_040_LESS(A) 1 -#else - #define CPU_TYPE_IS_040_PLUS(A) 0 - #define CPU_TYPE_IS_040_LESS(A) 1 -#endif - -#if M68K_EMULATE_020 - #define CPU_TYPE_IS_020_PLUS(A) ((A) & (CPU_TYPE_020 | CPU_TYPE_040)) - #define CPU_TYPE_IS_020_LESS(A) 1 -#else - #define CPU_TYPE_IS_020_PLUS(A) CPU_TYPE_IS_040_PLUS(A) - #define CPU_TYPE_IS_020_LESS(A) CPU_TYPE_IS_040_LESS(A) -#endif - -#if M68K_EMULATE_EC020 - #define CPU_TYPE_IS_EC020_PLUS(A) ((A) & (CPU_TYPE_EC020 | CPU_TYPE_020 | CPU_TYPE_040)) - #define CPU_TYPE_IS_EC020_LESS(A) ((A) & (CPU_TYPE_000 | CPU_TYPE_008 | CPU_TYPE_010 | CPU_TYPE_EC020)) -#else - #define CPU_TYPE_IS_EC020_PLUS(A) CPU_TYPE_IS_020_PLUS(A) - #define CPU_TYPE_IS_EC020_LESS(A) CPU_TYPE_IS_020_LESS(A) -#endif - -#if M68K_EMULATE_010 - #define CPU_TYPE_IS_010(A) ((A) == CPU_TYPE_010) - #define CPU_TYPE_IS_010_PLUS(A) ((A) & (CPU_TYPE_010 | CPU_TYPE_EC020 | CPU_TYPE_020 | CPU_TYPE_040)) - #define CPU_TYPE_IS_010_LESS(A) ((A) & (CPU_TYPE_000 | CPU_TYPE_008 | CPU_TYPE_010)) -#else - #define CPU_TYPE_IS_010(A) 0 - #define CPU_TYPE_IS_010_PLUS(A) CPU_TYPE_IS_EC020_PLUS(A) - #define CPU_TYPE_IS_010_LESS(A) CPU_TYPE_IS_EC020_LESS(A) -#endif - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 - #define CPU_TYPE_IS_020_VARIANT(A) ((A) & (CPU_TYPE_EC020 | CPU_TYPE_020)) -#else - #define CPU_TYPE_IS_020_VARIANT(A) 0 -#endif - -#if M68K_EMULATE_040 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_010 - #define CPU_TYPE_IS_000(A) ((A) == CPU_TYPE_000 || (A) == CPU_TYPE_008) -#else - #define CPU_TYPE_IS_000(A) 1 -#endif - - -#if !M68K_SEPARATE_READS -#define m68k_read_immediate_16(A) m68ki_read_program_16(A) -#define m68k_read_immediate_32(A) m68ki_read_program_32(A) - -#define m68k_read_pcrelative_8(A) m68ki_read_program_8(A) -#define m68k_read_pcrelative_16(A) m68ki_read_program_16(A) -#define m68k_read_pcrelative_32(A) m68ki_read_program_32(A) -#endif /* M68K_SEPARATE_READS */ - - /* Enable or disable callback functions */ #if M68K_EMULATE_INT_ACK #if M68K_EMULATE_INT_ACK == OPT_SPECIFY_HANDLER - #define m68ki_int_ack(A) M68K_INT_ACK_CALLBACK(A) + #define m68ki_int_ack(A) M68K_INT_ACK_CALLBACK(A); #else - #define m68ki_int_ack(A) CALLBACK_INT_ACK(A) + #define m68ki_int_ack(A) CALLBACK_INT_ACK(A); #endif #else /* Default action is to used autovector mode, which is most common */ #define m68ki_int_ack(A) M68K_INT_ACK_AUTOVECTOR #endif /* M68K_EMULATE_INT_ACK */ -#if M68K_EMULATE_BKPT_ACK - #if M68K_EMULATE_BKPT_ACK == OPT_SPECIFY_HANDLER - #define m68ki_bkpt_ack(A) M68K_BKPT_ACK_CALLBACK(A) - #else - #define m68ki_bkpt_ack(A) CALLBACK_BKPT_ACK(A) - #endif -#else - #define m68ki_bkpt_ack(A) -#endif /* M68K_EMULATE_BKPT_ACK */ - #if M68K_EMULATE_RESET #if M68K_EMULATE_RESET == OPT_SPECIFY_HANDLER - #define m68ki_output_reset() M68K_RESET_CALLBACK() + #define m68ki_output_reset() M68K_RESET_CALLBACK(); #else - #define m68ki_output_reset() CALLBACK_RESET_INSTR() + #define m68ki_output_reset() CALLBACK_RESET_INSTR(); #endif #else #define m68ki_output_reset() #endif /* M68K_EMULATE_RESET */ -#if M68K_CMPILD_HAS_CALLBACK - #if M68K_CMPILD_HAS_CALLBACK == OPT_SPECIFY_HANDLER - #define m68ki_cmpild_callback(v,r) M68K_CMPILD_CALLBACK(v,r) - #else - #define m68ki_cmpild_callback(v,r) CALLBACK_CMPILD_INSTR(v,r) - #endif -#else - #define m68ki_cmpild_callback(v,r) -#endif /* M68K_CMPILD_HAS_CALLBACK */ - -#if M68K_RTE_HAS_CALLBACK - #if M68K_RTE_HAS_CALLBACK == OPT_SPECIFY_HANDLER - #define m68ki_rte_callback() M68K_RTE_CALLBACK() - #else - #define m68ki_rte_callback() CALLBACK_RTE_INSTR() - #endif -#else - #define m68ki_rte_callback() -#endif /* M68K_RTE_HAS_CALLBACK */ - #if M68K_TAS_HAS_CALLBACK #if M68K_TAS_HAS_CALLBACK == OPT_SPECIFY_HANDLER #define m68ki_tas_callback() M68K_TAS_CALLBACK() @@ -492,36 +395,15 @@ #endif /* M68K_TAS_HAS_CALLBACK */ -#if M68K_INSTRUCTION_HOOK - #if M68K_INSTRUCTION_HOOK == OPT_SPECIFY_HANDLER - #define m68ki_instr_hook(pc) M68K_INSTRUCTION_CALLBACK(pc) - #else - #define m68ki_instr_hook(pc) CALLBACK_INSTR_HOOK(pc) - #endif -#else - #define m68ki_instr_hook(pc) -#endif /* M68K_INSTRUCTION_HOOK */ - -#if M68K_MONITOR_PC - #if M68K_MONITOR_PC == OPT_SPECIFY_HANDLER - #define m68ki_pc_changed(A) M68K_SET_PC_CALLBACK(ADDRESS_68K(A)) - #else - #define m68ki_pc_changed(A) CALLBACK_PC_CHANGED(ADDRESS_68K(A)) - #endif -#else - #define m68ki_pc_changed(A) -#endif /* M68K_MONITOR_PC */ - - /* Enable or disable function code emulation */ #if M68K_EMULATE_FC #if M68K_EMULATE_FC == OPT_SPECIFY_HANDLER - #define m68ki_set_fc(A) M68K_SET_FC_CALLBACK(A) + #define m68ki_set_fc(A) M68K_SET_FC_CALLBACK(A); #else - #define m68ki_set_fc(A) CALLBACK_SET_FC(A) + #define m68ki_set_fc(A) CALLBACK_SET_FC(A); #endif - #define m68ki_use_data_space() m68ki_address_space = FUNCTION_CODE_USER_DATA - #define m68ki_use_program_space() m68ki_address_space = FUNCTION_CODE_USER_PROGRAM + #define m68ki_use_data_space() m68ki_address_space = FUNCTION_CODE_USER_DATA; + #define m68ki_use_program_space() m68ki_address_space = FUNCTION_CODE_USER_PROGRAM; #define m68ki_get_address_space() m68ki_address_space #else #define m68ki_set_fc(A) @@ -534,28 +416,20 @@ /* Enable or disable trace emulation */ #if M68K_EMULATE_TRACE /* Initiates trace checking before each instruction (t1) */ - #define m68ki_trace_t1() m68ki_tracing = FLAG_T1 - /* adds t0 to trace checking if we encounter change of flow */ - #define m68ki_trace_t0() m68ki_tracing |= FLAG_T0 + #define m68ki_trace_t1() m68ki_tracing = FLAG_T1; /* Clear all tracing */ - #define m68ki_clear_trace() m68ki_tracing = 0 + #define m68ki_clear_trace() m68ki_tracing = 0; /* Cause a trace exception if we are tracing */ - #define m68ki_exception_if_trace() if(m68ki_tracing) m68ki_exception_trace() + #define m68ki_exception_if_trace() if(m68ki_tracing) m68ki_exception_trace(); #else #define m68ki_trace_t1() - #define m68ki_trace_t0() #define m68ki_clear_trace() #define m68ki_exception_if_trace() #endif /* M68K_EMULATE_TRACE */ - -/* Address error */ +/* Enable or disable Address error emulation */ #if M68K_EMULATE_ADDRESS_ERROR - #include - extern jmp_buf m68ki_aerr_trap; - extern int emulate_address_error; - #define m68ki_set_address_error_trap() \ if(setjmp(m68ki_aerr_trap) != 0) \ { \ @@ -573,41 +447,11 @@ longjmp(m68ki_aerr_trap, 1); \ } \ } - #define m68ki_check_address_error_010_less(ADDR, WRITE_MODE, FC) \ - if (CPU_TYPE_IS_010_LESS(CPU_TYPE)) \ - { \ - m68ki_check_address_error(ADDR, WRITE_MODE, FC) \ - } #else #define m68ki_set_address_error_trap() #define m68ki_check_address_error(ADDR, WRITE_MODE, FC) - #define m68ki_check_address_error_010_less(ADDR, WRITE_MODE, FC) #endif /* M68K_ADDRESS_ERROR */ -/* Logging */ -#if M68K_LOG_ENABLE - #include - extern FILE* M68K_LOG_FILEHANDLE - extern const char *const m68ki_cpu_names[]; - - #define M68K_DO_LOG(A) if(M68K_LOG_FILEHANDLE) fprintf A - #if M68K_LOG_1010_1111 - #define M68K_DO_LOG_EMU(A) if(M68K_LOG_FILEHANDLE) fprintf A - #else - #define M68K_DO_LOG_EMU(A) - #endif -#else - #define M68K_DO_LOG(A) - #define M68K_DO_LOG_EMU(A) -#endif - -#if M68K_CHECK_INFINITE_LOOP - #define m68ki_check_infinite_loop() if(REG_PC == REG_PPC) USE_ALL_CYCLES() -#else - #define m68ki_check_infinite_loop() -#endif /* M68K_CHECK_INFINITE_LOOP */ - - /* -------------------------- EA / Operand Access ------------------------- */ @@ -616,14 +460,15 @@ * .... XXX. .... .YYY * where XXX is register X and YYY is register Y */ + /* Data Register Isolation */ #define DX (REG_D[(REG_IR >> 9) & 7]) #define DY (REG_D[REG_IR & 7]) + /* Address Register Isolation */ #define AX (REG_A[(REG_IR >> 9) & 7]) #define AY (REG_A[REG_IR & 7]) - /* Effective Address Calculations */ #define EA_AY_AI_8() AY /* address register indirect */ #define EA_AY_AI_16() EA_AY_AI_8() @@ -679,7 +524,6 @@ #define OPER_I_32() m68ki_read_imm_32() - /* --------------------------- Status Register ---------------------------- */ /* Flag Calculation Macros */ @@ -723,11 +567,8 @@ #define VFLAG_CLEAR 0 #define ZFLAG_SET 0 #define ZFLAG_CLEAR 0xffffffff - #define SFLAG_SET 4 #define SFLAG_CLEAR 0 -#define MFLAG_SET 2 -#define MFLAG_CLEAR 0 /* Turn flag values into 1 or 0 */ #define XFLAG_AS_1() ((FLAG_X>>8)&1) @@ -782,10 +623,8 @@ (COND_CS() >> 8)) /* Get the status register */ -#define m68ki_get_sr() ( FLAG_T1 | \ - FLAG_T0 | \ +#define m68ki_get_sr() ( FLAG_T1 | \ (FLAG_S << 11) | \ - (FLAG_M << 11) | \ FLAG_INT_MASK | \ m68ki_get_ccr()) @@ -793,15 +632,8 @@ /* ---------------------------- Cycle Counting ---------------------------- */ -/* -#define ADD_CYCLES(A) m68ki_remaining_cycles += (A) -#define USE_CYCLES(A) m68ki_remaining_cycles -= (A) -#define SET_CYCLES(A) m68ki_remaining_cycles = A -#define GET_CYCLES() m68ki_remaining_cycles -#define USE_ALL_CYCLES() m68ki_remaining_cycles = 0 -*/ - #define USE_CYCLES(A) mcycles_68k += (A) +#define END_CYCLES(A) mcycles_68k = (A) /* ----------------------------- Read / Write ----------------------------- */ @@ -816,12 +648,6 @@ #define m68ki_write_16(A, V) m68ki_write_16_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA, V) #define m68ki_write_32(A, V) m68ki_write_32_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA, V) -#if M68K_SIMULATE_PD_WRITES -#define m68ki_write_32_pd(A, V) m68ki_write_32_pd_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA, V) -#else -#define m68ki_write_32_pd(A, V) m68ki_write_32_fc(A, FLAG_S | FUNCTION_CODE_USER_DATA, V) -#endif - /* map read immediate 8 to read immediate 16 */ #define m68ki_read_imm_8() MASK_OUT_ABOVE_8(m68ki_read_imm_16()) @@ -846,33 +672,14 @@ /* =============================== PROTOTYPES ============================= */ /* ======================================================================== */ -typedef union -{ - uint64 i; - double f; -} fp_reg; - typedef struct { - uint cpu_type; /* CPU Type: 68000, 68008, 68010, 68EC020, or 68020 */ uint dar[16]; /* Data and Address Registers */ - uint ppc; /* Previous program counter */ uint pc; /* Program Counter */ - uint sp[7]; /* User, Interrupt, and Master Stack Pointers */ - uint vbr; /* Vector Base Register (m68010+) */ - uint sfc; /* Source Function Code Register (m68010+) */ - uint dfc; /* Destination Function Code Register (m68010+) */ - uint cacr; /* Cache Control Register (m68020, unemulated) */ - uint caar; /* Cache Address Register (m68020, unemulated) */ + uint sp[5]; /* User and Interrupt Stack Pointers */ uint ir; /* Instruction Register */ - fp_reg fpr[8]; /* FPU Data Register (m68040) */ - uint fpiar; /* FPU Instruction Address Register (m68040) */ - uint fpsr; /* FPU Status Register (m68040) */ - uint fpcr; /* FPU Control Register (m68040) */ uint t1_flag; /* Trace 1 */ - uint t0_flag; /* Trace 0 */ uint s_flag; /* Supervisor */ - uint m_flag; /* Master/Interrupt state */ uint x_flag; /* Extend */ uint n_flag; /* Negative */ uint not_z_flag; /* Zero, inverted for speedups */ @@ -881,60 +688,174 @@ typedef struct uint int_mask; /* I0-I2 */ uint int_level; /* State of interrupt pins IPL0-IPL2 -- ASG: changed from ints_pending */ uint stopped; /* Stopped state */ +#if M68K_EMULATE_PREFETCH uint pref_addr; /* Last prefetch address */ uint pref_data; /* Data in the prefetch queue */ - uint address_mask; /* Available address pins */ - uint sr_mask; /* Implemented status register bits */ +#endif +#if M68K_EMULATE_ADDRESS_ERROR uint instr_mode; /* Stores whether we are in instruction mode or group 0/1 exception mode */ uint run_mode; /* Stores whether we are processing a reset, bus error, address error, or something else */ - - /* Clocks required for instructions / exceptions */ - uint cyc_bcc_notake_b; - uint cyc_bcc_notake_w; - uint cyc_dbcc_f_noexp; - uint cyc_dbcc_f_exp; - uint cyc_scc_r_true; - uint cyc_movem_w; - uint cyc_movem_l; - uint cyc_shift; - uint cyc_reset; - const uint8* cyc_instruction; - const uint16* cyc_exception; +#endif /* Callbacks to host */ +#if M68K_EMULATE_INT_ACK == OPT_ON int (*int_ack_callback)(int int_line); /* Interrupt Acknowledge */ - void (*bkpt_ack_callback)(unsigned int data); /* Breakpoint Acknowledge */ +#endif +#if M68K_EMULATE_RESET == OPT_ON void (*reset_instr_callback)(void); /* Called when a RESET instruction is encountered */ - void (*cmpild_instr_callback)(unsigned int, int); /* Called when a CMPI.L #v, Dn instruction is encountered */ - void (*rte_instr_callback)(void); /* Called when a RTE instruction is encountered */ +#endif +#if M68K_TAS_HAS_CALLBACK == OPT_ON int (*tas_instr_callback)(void); /* Called when a TAS instruction is encountered, allows / disallows writeback */ - void (*pc_changed_callback)(unsigned int new_pc); /* Called when the PC changes by a large amount */ +#endif +#if M68K_EMULATE_FC == OPT_ON void (*set_fc_callback)(unsigned int new_fc); /* Called when the CPU function code changes */ - void (*instr_hook_callback)(unsigned int pc); /* Called every instruction cycle prior to execution */ - +#endif } m68ki_cpu_core; -extern unsigned int mcycles_68k; +/* The CPU core */ +m68ki_cpu_core m68ki_cpu; + +/* Prevent static data from being redefined when this file is included */ +#ifndef _MEM68K_H_ -extern m68ki_cpu_core m68ki_cpu; -#if 0 -extern sint m68ki_remaining_cycles; -#endif #if M68K_EMULATE_TRACE -extern uint m68ki_tracing; -#endif -extern const uint8 m68ki_shift_8_table[]; -extern const uint16 m68ki_shift_16_table[]; -extern const uint m68ki_shift_32_table[]; -extern uint16 m68ki_exception_cycle_table[][256]; -#if M68K_EMULATE_FC -extern uint m68ki_address_space; -#endif -extern const uint8 m68ki_ea_idx_cycle_table[]; +static uint m68ki_tracing; +#endif /* M68K_EMULATE_TRACE */ -extern uint m68ki_aerr_address; -extern uint m68ki_aerr_write_mode; -extern uint m68ki_aerr_fc; +#if M68K_EMULATE_FC +static uint m68ki_address_space; +#endif /* M68K_EMULATE_FC */ + +#if M68K_EMULATE_ADDRESS_ERROR +static jmp_buf m68ki_aerr_trap; +static uint m68ki_aerr_address; +static uint m68ki_aerr_write_mode; +static uint m68ki_aerr_fc; +int emulate_address_error; +#endif /* M68K_EMULATE_ADDRESS_ERROR */ + +/* Current end cycle */ +static unsigned int end_cycles; + +/* Cycles used by CPU instructions */ +static unsigned char m68ki_cycles[0x10000]; + +/* Used by shift & rotate instructions */ +static const uint8 m68ki_shift_8_table[65] = +{ + 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff +}; + +static const uint16 m68ki_shift_16_table[65] = +{ + 0x0000, 0x8000, 0xc000, 0xe000, 0xf000, 0xf800, 0xfc00, 0xfe00, 0xff00, + 0xff80, 0xffc0, 0xffe0, 0xfff0, 0xfff8, 0xfffc, 0xfffe, 0xffff, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, + 0xffff, 0xffff +}; + +static const uint m68ki_shift_32_table[65] = +{ + 0x00000000, 0x80000000, 0xc0000000, 0xe0000000, 0xf0000000, 0xf8000000, + 0xfc000000, 0xfe000000, 0xff000000, 0xff800000, 0xffc00000, 0xffe00000, + 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000, 0xffff8000, + 0xffffc000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, + 0xffffff00, 0xffffff80, 0xffffffc0, 0xffffffe0, 0xfffffff0, 0xfffffff8, + 0xfffffffc, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff +}; + + +/* Number of clock cycles to use for exception processing. + * I used 4 for any vectors that are undocumented for processing times. + */ +static const uint16 m68ki_exception_cycle_table[256] = +{ + 40*7, /* 0: Reset - Initial Stack Pointer */ + 4*7, /* 1: Reset - Initial Program Counter */ + 50*7, /* 2: Bus Error (unemulated) */ + 50*7, /* 3: Address Error (unemulated) */ + 34*7, /* 4: Illegal Instruction */ + 38*7, /* 5: Divide by Zero -- ASG: changed from 42 */ + 40*7, /* 6: CHK -- ASG: chanaged from 44 */ + 34*7, /* 7: TRAPV */ + 34*7, /* 8: Privilege Violation */ + 34*7, /* 9: Trace */ + 4*7, /* 10: 1010 */ + 4*7, /* 11: 1111 */ + 4*7, /* 12: RESERVED */ + 4*7, /* 13: Coprocessor Protocol Violation (unemulated) */ + 4*7, /* 14: Format Error */ + 44*7, /* 15: Uninitialized Interrupt */ + 4*7, /* 16: RESERVED */ + 4*7, /* 17: RESERVED */ + 4*7, /* 18: RESERVED */ + 4*7, /* 19: RESERVED */ + 4*7, /* 20: RESERVED */ + 4*7, /* 21: RESERVED */ + 4*7, /* 22: RESERVED */ + 4*7, /* 23: RESERVED */ + 44*7, /* 24: Spurious Interrupt */ + 44*7, /* 25: Level 1 Interrupt Autovector */ + 44*7, /* 26: Level 2 Interrupt Autovector */ + 44*7, /* 27: Level 3 Interrupt Autovector */ + 44*7, /* 28: Level 4 Interrupt Autovector */ + 44*7, /* 29: Level 5 Interrupt Autovector */ + 44*7, /* 30: Level 6 Interrupt Autovector */ + 44*7, /* 31: Level 7 Interrupt Autovector */ + 34*7, /* 32: TRAP #0 -- ASG: chanaged from 38 */ + 34*7, /* 33: TRAP #1 */ + 34*7, /* 34: TRAP #2 */ + 34*7, /* 35: TRAP #3 */ + 34*7, /* 36: TRAP #4 */ + 34*7, /* 37: TRAP #5 */ + 34*7, /* 38: TRAP #6 */ + 34*7, /* 39: TRAP #7 */ + 34*7, /* 40: TRAP #8 */ + 34*7, /* 41: TRAP #9 */ + 34*7, /* 42: TRAP #10 */ + 34*7, /* 43: TRAP #11 */ + 34*7, /* 44: TRAP #12 */ + 34*7, /* 45: TRAP #13 */ + 34*7, /* 46: TRAP #14 */ + 34*7, /* 47: TRAP #15 */ + 4*7, /* 48: FP Branch or Set on Unknown Condition (unemulated) */ + 4*7, /* 49: FP Inexact Result (unemulated) */ + 4*7, /* 50: FP Divide by Zero (unemulated) */ + 4*7, /* 51: FP Underflow (unemulated) */ + 4*7, /* 52: FP Operand Error (unemulated) */ + 4*7, /* 53: FP Overflow (unemulated) */ + 4*7, /* 54: FP Signaling NAN (unemulated) */ + 4*7, /* 55: FP Unimplemented Data Type (unemulated) */ + 4*7, /* 56: MMU Configuration Error (unemulated) */ + 4*7, /* 57: MMU Illegal Operation Error (unemulated) */ + 4*7, /* 58: MMU Access Level Violation Error (unemulated) */ + 4*7, /* 59: RESERVED */ + 4*7, /* 60: RESERVED */ + 4*7, /* 61: RESERVED */ + 4*7, /* 62: RESERVED */ + 4*7, /* 63: RESERVED */ + /* 64-255: User Defined */ + 4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7, + 4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7, + 4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7, + 4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7, + 4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7, + 4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7,4*7 +}; /* Read data immediately after the program counter */ INLINE uint m68ki_read_imm_16(void); @@ -949,9 +870,6 @@ INLINE uint m68ki_read_32_fc (uint address, uint fc); INLINE void m68ki_write_8_fc (uint address, uint fc, uint value); INLINE void m68ki_write_16_fc(uint address, uint fc, uint value); INLINE void m68ki_write_32_fc(uint address, uint fc, uint value); -#if M68K_SIMULATE_PD_WRITES -INLINE void m68ki_write_32_pd_fc(uint address, uint fc, uint value); -#endif /* M68K_SIMULATE_PD_WRITES */ /* Indexed and PC-relative ea fetching */ INLINE uint m68ki_get_ea_pcdi(void); @@ -1022,39 +940,33 @@ INLINE void m68ki_branch_32(uint offset); /* Status register operations. */ INLINE void m68ki_set_s_flag(uint value); /* Only bit 2 of value should be set (i.e. 4 or 0) */ -INLINE void m68ki_set_sm_flag(uint value); /* only bits 1 and 2 of value should be set */ INLINE void m68ki_set_ccr(uint value); /* set the condition code register */ INLINE void m68ki_set_sr(uint value); /* set the status register */ -INLINE void m68ki_set_sr_noint(uint value); /* set the status register */ /* Exception processing */ INLINE uint m68ki_init_exception(void); /* Initial exception processing */ - INLINE void m68ki_stack_frame_3word(uint pc, uint sr); /* Stack various frame types */ +#if M68K_EMULATE_ADDRESS_ERROR INLINE void m68ki_stack_frame_buserr(uint sr); - -INLINE void m68ki_stack_frame_0000(uint pc, uint sr, uint vector); -INLINE void m68ki_stack_frame_0001(uint pc, uint sr, uint vector); -INLINE void m68ki_stack_frame_0010(uint sr, uint vector); -INLINE void m68ki_stack_frame_1000(uint pc, uint sr, uint vector); -INLINE void m68ki_stack_frame_1010(uint sr, uint vector, uint pc); -INLINE void m68ki_stack_frame_1011(uint sr, uint vector, uint pc); - +#endif INLINE void m68ki_exception_trap(uint vector); INLINE void m68ki_exception_trapN(uint vector); +#if M68K_EMULATE_TRACE INLINE void m68ki_exception_trace(void); -INLINE void m68ki_exception_privilege_violation(void); +#endif +static void m68ki_exception_privilege_violation(void); /* do not inline in order to reduce function size and allow inlining of read/write functions by the compile */ INLINE void m68ki_exception_1010(void); INLINE void m68ki_exception_1111(void); INLINE void m68ki_exception_illegal(void); -INLINE void m68ki_exception_format_error(void); +#if M68K_EMULATE_ADDRESS_ERROR INLINE void m68ki_exception_address_error(void); +#endif INLINE void m68ki_exception_interrupt(uint int_level); INLINE void m68ki_check_interrupts(void); /* ASG: check for interrupts */ -/* quick disassembly (used for logging) */ -char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type); - +/* External ressources (specific to Genesis Plus GX core) */ +extern int vdp_68k_irq_ack(int int_level); +extern uint32 mcycles_68k; /* ======================================================================== */ /* =========================== UTILITY FUNCTIONS ========================== */ @@ -1068,8 +980,10 @@ char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type); */ INLINE uint m68ki_read_imm_16(void) { - m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ - m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM) /* auto-disable (see m68kcpu.h) */ +#if M68K_CHECK_PC_ADDRESS_ERROR + m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM) /* auto-disable (see m68kcpu.h) */ +#endif #if M68K_EMULATE_PREFETCH if(MASK_OUT_BELOW_2(REG_PC) != CPU_PREF_ADDR) { @@ -1079,8 +993,9 @@ INLINE uint m68ki_read_imm_16(void) REG_PC += 2; return MASK_OUT_ABOVE_16(CPU_PREF_DATA >> ((2-((REG_PC-2)&2))<<3)); #else + uint pc = REG_PC; REG_PC += 2; - return m68k_read_immediate_16(REG_PC-2); + return m68k_read_immediate_16(pc); #endif /* M68K_EMULATE_PREFETCH */ } @@ -1089,8 +1004,10 @@ INLINE uint m68ki_read_imm_32(void) #if M68K_EMULATE_PREFETCH uint temp_val; - m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ - m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM) /* auto-disable (see m68kcpu.h) */ +#if M68K_CHECK_PC_ADDRESS_ERROR + m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM) /* auto-disable (see m68kcpu.h) */ +#endif if(MASK_OUT_BELOW_2(REG_PC) != CPU_PREF_ADDR) { CPU_PREF_ADDR = MASK_OUT_BELOW_2(REG_PC); @@ -1108,10 +1025,13 @@ INLINE uint m68ki_read_imm_32(void) return temp_val; #else - m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ - m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM) /* auto-disable (see m68kcpu.h) */ +#if M68K_CHECK_PC_ADDRESS_ERROR + m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM) /* auto-disable (see m68kcpu.h) */ +#endif + uint pc = REG_PC; REG_PC += 4; - return m68k_read_immediate_32(REG_PC-4); + return m68k_read_immediate_32(pc); #endif /* M68K_EMULATE_PREFETCH */ } @@ -1127,7 +1047,7 @@ INLINE uint m68ki_read_imm_32(void) */ INLINE uint m68ki_read_8_fc(uint address, uint fc) { - m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(fc) /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->read8) return (*temp->read8)(ADDRESS_68K(address)); @@ -1136,8 +1056,8 @@ INLINE uint m68ki_read_8_fc(uint address, uint fc) INLINE uint m68ki_read_16_fc(uint address, uint fc) { - m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ - m68ki_check_address_error_010_less(address, MODE_READ, fc); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(fc) /* auto-disable (see m68kcpu.h) */ + m68ki_check_address_error(address, MODE_READ, fc) /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->read16) return (*temp->read16)(ADDRESS_68K(address)); @@ -1146,8 +1066,8 @@ INLINE uint m68ki_read_16_fc(uint address, uint fc) INLINE uint m68ki_read_32_fc(uint address, uint fc) { - m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ - m68ki_check_address_error_010_less(address, MODE_READ, fc); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(fc) /* auto-disable (see m68kcpu.h) */ + m68ki_check_address_error(address, MODE_READ, fc) /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->read16) return ((*temp->read16)(ADDRESS_68K(address)) << 16) | ((*temp->read16)(ADDRESS_68K(address + 2))); @@ -1156,7 +1076,7 @@ INLINE uint m68ki_read_32_fc(uint address, uint fc) INLINE void m68ki_write_8_fc(uint address, uint fc, uint value) { - m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(fc) /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->write8) (*temp->write8)(ADDRESS_68K(address),value); @@ -1165,8 +1085,8 @@ INLINE void m68ki_write_8_fc(uint address, uint fc, uint value) INLINE void m68ki_write_16_fc(uint address, uint fc, uint value) { - m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ - m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(fc) /* auto-disable (see m68kcpu.h) */ + m68ki_check_address_error(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->write16) (*temp->write16)(ADDRESS_68K(address),value); @@ -1175,8 +1095,8 @@ INLINE void m68ki_write_16_fc(uint address, uint fc, uint value) INLINE void m68ki_write_32_fc(uint address, uint fc, uint value) { - m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ - m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */ + m68ki_set_fc(fc) /* auto-disable (see m68kcpu.h) */ + m68ki_check_address_error(address, MODE_WRITE, fc) /* auto-disable (see m68kcpu.h) */ _m68k_memory_map *temp = &m68k_memory_map[((address)>>16)&0xff]; if (temp->write16) (*temp->write16)(ADDRESS_68K(address),value>>16); @@ -1187,15 +1107,6 @@ INLINE void m68ki_write_32_fc(uint address, uint fc, uint value) else *(uint16 *)(temp->base + ((address + 2) & 0xffff)) = value; } -#if M68K_SIMULATE_PD_WRITES -INLINE void m68ki_write_32_pd_fc(uint address, uint fc, uint value) -{ - m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */ - m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */ - m68k_write_memory_32_pd(ADDRESS_68K(address), value); -} -#endif - /* --------------------- Effective Address Calculation -------------------- */ @@ -1205,14 +1116,14 @@ INLINE void m68ki_write_32_pd_fc(uint address, uint fc, uint value) INLINE uint m68ki_get_ea_pcdi(void) { uint old_pc = REG_PC; - m68ki_use_program_space(); /* auto-disable */ + m68ki_use_program_space() /* auto-disable */ return old_pc + MAKE_INT_16(m68ki_read_imm_16()); } INLINE uint m68ki_get_ea_pcix(void) { - m68ki_use_program_space(); /* auto-disable */ + m68ki_use_program_space() /* auto-disable */ return m68ki_get_ea_ix(REG_PC); } @@ -1262,75 +1173,16 @@ INLINE uint m68ki_get_ea_ix(uint An) { /* An = base register */ uint extension = m68ki_read_imm_16(); + uint Xn = 0; /* Index register */ - if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) - { - /* Calculate index */ - Xn = REG_DA[extension>>12]; /* Xn */ - if(!BIT_B(extension)) /* W/L */ - Xn = MAKE_INT_16(Xn); + /* Calculate index */ + Xn = REG_DA[extension>>12]; /* Xn */ + if(!BIT_B(extension)) /* W/L */ + Xn = MAKE_INT_16(Xn); - /* Add base register and displacement and return */ - return An + Xn + MAKE_INT_8(extension); - } - -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - - uint bd = 0; /* Base Displacement */ - uint od = 0; /* Outer Displacement */ - - /* Brief extension format */ - if(!BIT_8(extension)) - { - /* Calculate index */ - Xn = REG_DA[extension>>12]; /* Xn */ - if(!BIT_B(extension)) /* W/L */ - Xn = MAKE_INT_16(Xn); - /* Add scale if proper CPU type */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - Xn <<= (extension>>9) & 3; /* SCALE */ - - /* Add base register and displacement and return */ - return An + Xn + MAKE_INT_8(extension); - } - - /* Full extension format */ - - USE_CYCLES(m68ki_ea_idx_cycle_table[extension&0x3f]); - - /* Check if base register is present */ - if(BIT_7(extension)) /* BS */ - An = 0; /* An */ - - /* Check if index is present */ - if(!BIT_6(extension)) /* IS */ - { - Xn = REG_DA[extension>>12]; /* Xn */ - if(!BIT_B(extension)) /* W/L */ - Xn = MAKE_INT_16(Xn); - Xn <<= (extension>>9) & 3; /* SCALE */ - } - - /* Check if base displacement is present */ - if(BIT_5(extension)) /* BD SIZE */ - bd = BIT_4(extension) ? m68ki_read_imm_32() : MAKE_INT_16(m68ki_read_imm_16()); - - /* If no indirect action, we are done */ - if(!(extension&7)) /* No Memory Indirect */ - return An + bd + Xn; - - /* Check if outer displacement is present */ - if(BIT_1(extension)) /* I/IS: od */ - od = BIT_0(extension) ? m68ki_read_imm_32() : MAKE_INT_16(m68ki_read_imm_16()); - - /* Postindex */ - if(BIT_2(extension)) /* I/IS: 0 = preindex, 1 = postindex */ - return m68ki_read_32(An + bd) + Xn + od; - - /* Preindex */ - return m68ki_read_32(An + bd + Xn) + od; -#endif + /* Add base register and displacement and return */ + return An + Xn + MAKE_INT_8(extension); } @@ -1413,29 +1265,6 @@ INLINE uint m68ki_pull_32(void) } -/* Increment/decrement the stack as if doing a push/pull but - * don't do any memory access. - */ -INLINE void m68ki_fake_push_16(void) -{ - REG_SP = MASK_OUT_ABOVE_32(REG_SP - 2); -} - -INLINE void m68ki_fake_push_32(void) -{ - REG_SP = MASK_OUT_ABOVE_32(REG_SP - 4); -} - -INLINE void m68ki_fake_pull_16(void) -{ - REG_SP = MASK_OUT_ABOVE_32(REG_SP + 2); -} - -INLINE void m68ki_fake_pull_32(void) -{ - REG_SP = MASK_OUT_ABOVE_32(REG_SP + 4); -} - /* ----------------------------- Program Flow ----------------------------- */ @@ -1446,18 +1275,11 @@ INLINE void m68ki_fake_pull_32(void) INLINE void m68ki_jump(uint new_pc) { REG_PC = new_pc; - m68ki_pc_changed(REG_PC); } INLINE void m68ki_jump_vector(uint vector) { -#if M68K_EMULATE_040 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_010 - REG_PC = (vector<<2) + REG_VBR; - REG_PC = m68ki_read_data_32(REG_PC); -#else REG_PC = m68ki_read_data_32(vector<<2); - m68ki_pc_changed(REG_PC); -#endif } @@ -1479,7 +1301,6 @@ INLINE void m68ki_branch_16(uint offset) INLINE void m68ki_branch_32(uint offset) { REG_PC += offset; - m68ki_pc_changed(REG_PC); } @@ -1492,33 +1313,11 @@ INLINE void m68ki_branch_32(uint offset) INLINE void m68ki_set_s_flag(uint value) { /* Backup the old stack pointer */ - REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)] = REG_SP; + REG_SP_BASE[FLAG_S] = REG_SP; /* Set the S flag */ FLAG_S = value; /* Set the new stack pointer */ - REG_SP = REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)]; -} - -/* Set the S and M flags and change the active stack pointer. - * Note that value MUST be 0, 2, 4, or 6 (bit2 = S, bit1 = M). - */ -INLINE void m68ki_set_sm_flag(uint value) -{ - /* Backup the old stack pointer */ - REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)] = REG_SP; - /* Set the S and M flags */ - FLAG_S = value & SFLAG_SET; - FLAG_M = value & MFLAG_SET; - /* Set the new stack pointer */ - REG_SP = REG_SP_BASE[FLAG_S | ((FLAG_S>>1) & FLAG_M)]; -} - -/* Set the S and M flags. Don't touch the stack pointer. */ -INLINE void m68ki_set_sm_flag_nosp(uint value) -{ - /* Set the S and M flags */ - FLAG_S = value & SFLAG_SET; - FLAG_M = value & MFLAG_SET; + REG_SP = REG_SP_BASE[FLAG_S]; } @@ -1532,40 +1331,17 @@ INLINE void m68ki_set_ccr(uint value) FLAG_C = BIT_0(value) << 8; } -/* Set the status register but don't check for interrupts */ -INLINE void m68ki_set_sr_noint(uint value) -{ - /* Mask out the "unimplemented" bits */ - value &= CPU_SR_MASK; - - /* Now set the status register */ - FLAG_T1 = BIT_F(value); - FLAG_T0 = BIT_E(value); - FLAG_INT_MASK = value & 0x0700; - m68ki_set_ccr(value); - m68ki_set_sm_flag((value >> 11) & 6); -} - -/* Set the status register but don't check for interrupts nor - * change the stack pointer - */ -INLINE void m68ki_set_sr_noint_nosp(uint value) -{ - /* Mask out the "unimplemented" bits */ - value &= CPU_SR_MASK; - - /* Now set the status register */ - FLAG_T1 = BIT_F(value); - FLAG_T0 = BIT_E(value); - FLAG_INT_MASK = value & 0x0700; - m68ki_set_ccr(value); - m68ki_set_sm_flag_nosp((value >> 11) & 6); -} /* Set the status register and check for interrupts */ INLINE void m68ki_set_sr(uint value) { - m68ki_set_sr_noint(value); + /* Set the status register */ + FLAG_T1 = BIT_F(value); + FLAG_INT_MASK = value & 0x0700; + m68ki_set_ccr(value); + m68ki_set_s_flag((value >> 11) & 4); + + /* Check current IRQ status */ m68ki_check_interrupts(); } @@ -1579,8 +1355,9 @@ INLINE uint m68ki_init_exception(void) uint sr = m68ki_get_sr(); /* Turn off trace flag, clear pending traces */ - FLAG_T1 = FLAG_T0 = 0; - m68ki_clear_trace(); + FLAG_T1 = 0; + m68ki_clear_trace() + /* Enter supervisor mode */ m68ki_set_s_flag(SFLAG_SET); @@ -1594,44 +1371,7 @@ INLINE void m68ki_stack_frame_3word(uint pc, uint sr) m68ki_push_16(sr); } -/* Format 0 stack frame. - * This is the standard stack frame for 68010+. - */ -INLINE void m68ki_stack_frame_0000(uint pc, uint sr, uint vector) -{ - /* Stack a 3-word frame if we are 68000 */ - if(CPU_TYPE == CPU_TYPE_000 || CPU_TYPE == CPU_TYPE_008) - { - m68ki_stack_frame_3word(pc, sr); - return; - } - m68ki_push_16(vector<<2); - m68ki_push_32(pc); - m68ki_push_16(sr); -} - -/* Format 1 stack frame (68020). - * For 68020, this is the 4 word throwaway frame. - */ -INLINE void m68ki_stack_frame_0001(uint pc, uint sr, uint vector) -{ - m68ki_push_16(0x1000 | (vector<<2)); - m68ki_push_32(pc); - m68ki_push_16(sr); -} - -/* Format 2 stack frame. - * This is used only by 68020 for trap exceptions. - */ -INLINE void m68ki_stack_frame_0010(uint sr, uint vector) -{ - m68ki_push_32(REG_PC-2); - m68ki_push_16(0x2000 | (vector<<2)); - m68ki_push_32(REG_PC); - m68ki_push_16(sr); -} - - +#if M68K_EMULATE_ADDRESS_ERROR /* Bus error stack frame (68000 only). */ INLINE void m68ki_stack_frame_buserr(uint sr) @@ -1647,190 +1387,15 @@ INLINE void m68ki_stack_frame_buserr(uint sr) */ m68ki_push_16(m68ki_aerr_write_mode | CPU_INSTR_MODE | m68ki_aerr_fc); } - -/* Format 8 stack frame (68010). - * 68010 only. This is the 29 word bus/address error frame. - */ -void m68ki_stack_frame_1000(uint pc, uint sr, uint vector) -{ - /* VERSION - * NUMBER - * INTERNAL INFORMATION, 16 WORDS - */ - m68ki_fake_push_32(); - m68ki_fake_push_32(); - m68ki_fake_push_32(); - m68ki_fake_push_32(); - m68ki_fake_push_32(); - m68ki_fake_push_32(); - m68ki_fake_push_32(); - m68ki_fake_push_32(); - - /* INSTRUCTION INPUT BUFFER */ - m68ki_push_16(0); - - /* UNUSED, RESERVED (not written) */ - m68ki_fake_push_16(); - - /* DATA INPUT BUFFER */ - m68ki_push_16(0); - - /* UNUSED, RESERVED (not written) */ - m68ki_fake_push_16(); - - /* DATA OUTPUT BUFFER */ - m68ki_push_16(0); - - /* UNUSED, RESERVED (not written) */ - m68ki_fake_push_16(); - - /* FAULT ADDRESS */ - m68ki_push_32(0); - - /* SPECIAL STATUS WORD */ - m68ki_push_16(0); - - /* 1000, VECTOR OFFSET */ - m68ki_push_16(0x8000 | (vector<<2)); - - /* PROGRAM COUNTER */ - m68ki_push_32(pc); - - /* STATUS REGISTER */ - m68ki_push_16(sr); -} - -/* Format A stack frame (short bus fault). - * This is used only by 68020 for bus fault and address error - * if the error happens at an instruction boundary. - * PC stacked is address of next instruction. - */ -void m68ki_stack_frame_1010(uint sr, uint vector, uint pc) -{ - /* INTERNAL REGISTER */ - m68ki_push_16(0); - - /* INTERNAL REGISTER */ - m68ki_push_16(0); - - /* DATA OUTPUT BUFFER (2 words) */ - m68ki_push_32(0); - - /* INTERNAL REGISTER */ - m68ki_push_16(0); - - /* INTERNAL REGISTER */ - m68ki_push_16(0); - - /* DATA CYCLE FAULT ADDRESS (2 words) */ - m68ki_push_32(0); - - /* INSTRUCTION PIPE STAGE B */ - m68ki_push_16(0); - - /* INSTRUCTION PIPE STAGE C */ - m68ki_push_16(0); - - /* SPECIAL STATUS REGISTER */ - m68ki_push_16(0); - - /* INTERNAL REGISTER */ - m68ki_push_16(0); - - /* 1010, VECTOR OFFSET */ - m68ki_push_16(0xa000 | (vector<<2)); - - /* PROGRAM COUNTER */ - m68ki_push_32(pc); - - /* STATUS REGISTER */ - m68ki_push_16(sr); -} - -/* Format B stack frame (long bus fault). - * This is used only by 68020 for bus fault and address error - * if the error happens during instruction execution. - * PC stacked is address of instruction in progress. - */ -void m68ki_stack_frame_1011(uint sr, uint vector, uint pc) -{ - /* INTERNAL REGISTERS (18 words) */ - m68ki_push_32(0); - m68ki_push_32(0); - m68ki_push_32(0); - m68ki_push_32(0); - m68ki_push_32(0); - m68ki_push_32(0); - m68ki_push_32(0); - m68ki_push_32(0); - m68ki_push_32(0); - - /* VERSION# (4 bits), INTERNAL INFORMATION */ - m68ki_push_16(0); - - /* INTERNAL REGISTERS (3 words) */ - m68ki_push_32(0); - m68ki_push_16(0); - - /* DATA INTPUT BUFFER (2 words) */ - m68ki_push_32(0); - - /* INTERNAL REGISTERS (2 words) */ - m68ki_push_32(0); - - /* STAGE B ADDRESS (2 words) */ - m68ki_push_32(0); - - /* INTERNAL REGISTER (4 words) */ - m68ki_push_32(0); - m68ki_push_32(0); - - /* DATA OUTPUT BUFFER (2 words) */ - m68ki_push_32(0); - - /* INTERNAL REGISTER */ - m68ki_push_16(0); - - /* INTERNAL REGISTER */ - m68ki_push_16(0); - - /* DATA CYCLE FAULT ADDRESS (2 words) */ - m68ki_push_32(0); - - /* INSTRUCTION PIPE STAGE B */ - m68ki_push_16(0); - - /* INSTRUCTION PIPE STAGE C */ - m68ki_push_16(0); - - /* SPECIAL STATUS REGISTER */ - m68ki_push_16(0); - - /* INTERNAL REGISTER */ - m68ki_push_16(0); - - /* 1011, VECTOR OFFSET */ - m68ki_push_16(0xb000 | (vector<<2)); - - /* PROGRAM COUNTER */ - m68ki_push_32(pc); - - /* STATUS REGISTER */ - m68ki_push_16(sr); -} - +#endif /* Used for Group 2 exceptions. - * These stack a type 2 frame on the 020. */ INLINE void m68ki_exception_trap(uint vector) { uint sr = m68ki_init_exception(); - if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) - m68ki_stack_frame_0000(REG_PC, sr, vector); - else - m68ki_stack_frame_0010(sr, vector); + m68ki_stack_frame_3word(REG_PC, sr); m68ki_jump_vector(vector); @@ -1842,31 +1407,24 @@ INLINE void m68ki_exception_trap(uint vector) INLINE void m68ki_exception_trapN(uint vector) { uint sr = m68ki_init_exception(); - m68ki_stack_frame_0000(REG_PC, sr, vector); + m68ki_stack_frame_3word(REG_PC, sr); m68ki_jump_vector(vector); /* Use up some clock cycles */ USE_CYCLES(CYC_EXCEPTION[vector]); } +#if M68K_EMULATE_TRACE /* Exception for trace mode */ INLINE void m68ki_exception_trace(void) { uint sr = m68ki_init_exception(); - if(CPU_TYPE_IS_010_LESS(CPU_TYPE)) - { - #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON - if(CPU_TYPE_IS_000(CPU_TYPE)) - { - CPU_INSTR_MODE = INSTRUCTION_NO; - } - #endif /* M68K_EMULATE_ADDRESS_ERROR */ - m68ki_stack_frame_0000(REG_PC, sr, EXCEPTION_TRACE); - } - else - m68ki_stack_frame_0010(sr, EXCEPTION_TRACE); + #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON + CPU_INSTR_MODE = INSTRUCTION_NO; + #endif /* M68K_EMULATE_ADDRESS_ERROR */ + m68ki_stack_frame_3word(REG_PC, sr); m68ki_jump_vector(EXCEPTION_TRACE); /* Trace nullifies a STOP instruction */ @@ -1875,20 +1433,18 @@ INLINE void m68ki_exception_trace(void) /* Use up some clock cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_TRACE]); } +#endif /* Exception for privilege violation */ -INLINE void m68ki_exception_privilege_violation(void) +static void m68ki_exception_privilege_violation(void) { uint sr = m68ki_init_exception(); #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON - if(CPU_TYPE_IS_000(CPU_TYPE)) - { - CPU_INSTR_MODE = INSTRUCTION_NO; - } + CPU_INSTR_MODE = INSTRUCTION_NO; #endif /* M68K_EMULATE_ADDRESS_ERROR */ - m68ki_stack_frame_0000(REG_PC-2, sr, EXCEPTION_PRIVILEGE_VIOLATION); + m68ki_stack_frame_3word(REG_PC-2, sr); m68ki_jump_vector(EXCEPTION_PRIVILEGE_VIOLATION); /* Use up some clock cycles and undo the instruction's cycles */ @@ -1898,15 +1454,8 @@ INLINE void m68ki_exception_privilege_violation(void) /* Exception for A-Line instructions */ INLINE void m68ki_exception_1010(void) { - uint sr; -#if M68K_LOG_1010_1111 == OPT_ON - M68K_DO_LOG_EMU((M68K_LOG_FILEHANDLE "%s at %08x: called 1010 instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC-2), REG_IR, - m68ki_disassemble_quick(ADDRESS_68K(REG_PC-2)))); -#endif - - sr = m68ki_init_exception(); - m68ki_stack_frame_0000(REG_PC-2, sr, EXCEPTION_1010); + uint sr = m68ki_init_exception(); + m68ki_stack_frame_3word(REG_PC-2, sr); m68ki_jump_vector(EXCEPTION_1010); /* Use up some clock cycles and undo the instruction's cycles */ @@ -1916,16 +1465,8 @@ INLINE void m68ki_exception_1010(void) /* Exception for F-Line instructions */ INLINE void m68ki_exception_1111(void) { - uint sr; - -#if M68K_LOG_1010_1111 == OPT_ON - M68K_DO_LOG_EMU((M68K_LOG_FILEHANDLE "%s at %08x: called 1111 instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC-2), REG_IR, - m68ki_disassemble_quick(ADDRESS_68K(REG_PC-2)))); -#endif - - sr = m68ki_init_exception(); - m68ki_stack_frame_0000(REG_PC-2, sr, EXCEPTION_1111); + uint sr = m68ki_init_exception(); + m68ki_stack_frame_3word(REG_PC-2, sr); m68ki_jump_vector(EXCEPTION_1111); /* Use up some clock cycles and undo the instruction's cycles */ @@ -1935,39 +1476,21 @@ INLINE void m68ki_exception_1111(void) /* Exception for illegal instructions */ INLINE void m68ki_exception_illegal(void) { - uint sr; - - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: illegal instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC-2), REG_IR, - m68ki_disassemble_quick(ADDRESS_68K(REG_PC-2)))); - - sr = m68ki_init_exception(); + uint sr = m68ki_init_exception(); #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON - if(CPU_TYPE_IS_000(CPU_TYPE)) - { - CPU_INSTR_MODE = INSTRUCTION_NO; - } + CPU_INSTR_MODE = INSTRUCTION_NO; #endif /* M68K_EMULATE_ADDRESS_ERROR */ - m68ki_stack_frame_0000(REG_PC-2, sr, EXCEPTION_ILLEGAL_INSTRUCTION); + m68ki_stack_frame_3word(REG_PC-2, sr); m68ki_jump_vector(EXCEPTION_ILLEGAL_INSTRUCTION); /* Use up some clock cycles and undo the instruction's cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_ILLEGAL_INSTRUCTION] - CYC_INSTRUCTION[REG_IR]); } -/* Exception for format errror in RTE */ -INLINE void m68ki_exception_format_error(void) -{ - uint sr = m68ki_init_exception(); - m68ki_stack_frame_0000(REG_PC, sr, EXCEPTION_FORMAT_ERROR); - m68ki_jump_vector(EXCEPTION_FORMAT_ERROR); - - /* Use up some clock cycles and undo the instruction's cycles */ - USE_CYCLES(CYC_EXCEPTION[EXCEPTION_FORMAT_ERROR] - CYC_INSTRUCTION[REG_IR]); -} +#if M68K_EMULATE_ADDRESS_ERROR /* Exception for address error */ INLINE void m68ki_exception_address_error(void) { @@ -1980,6 +1503,7 @@ INLINE void m68ki_exception_address_error(void) if(CPU_RUN_MODE == RUN_MODE_BERR_AERR_RESET) { CPU_STOPPED = STOP_LEVEL_HALT; + END_CYCLES(end_cycles); return; } CPU_RUN_MODE = RUN_MODE_BERR_AERR_RESET; @@ -1992,16 +1516,13 @@ INLINE void m68ki_exception_address_error(void) /* Use up some clock cycles and undo the instruction's cycles */ USE_CYCLES(CYC_EXCEPTION[EXCEPTION_ADDRESS_ERROR] - CYC_INSTRUCTION[REG_IR]); } - +#endif /* Service an interrupt request and start exception processing */ INLINE void m68ki_exception_interrupt(uint int_level) { #if M68K_EMULATE_ADDRESS_ERROR == OPT_ON - if(CPU_TYPE_IS_000(CPU_TYPE)) - { - CPU_INSTR_MODE = INSTRUCTION_NO; - } + CPU_INSTR_MODE = INSTRUCTION_NO; #endif /* M68K_EMULATE_ADDRESS_ERROR */ /* Turn off the stopped state */ @@ -2011,9 +1532,6 @@ INLINE void m68ki_exception_interrupt(uint int_level) if(CPU_STOPPED) return; - /* Acknowledge the interrupt */ - m68ki_int_ack(int_level); - /* Always use the autovectors. */ uint vector = EXCEPTION_INTERRUPT_AUTOVECTOR+int_level; @@ -2023,28 +1541,18 @@ INLINE void m68ki_exception_interrupt(uint int_level) /* Set the interrupt mask to the level of the one being serviced */ FLAG_INT_MASK = int_level<<8; + /* Acknowledge the interrupt */ + m68ki_int_ack(int_level) + /* Get the new PC */ -#if M68K_EMULATE_040 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_010 - uint new_pc = m68ki_read_data_32((vector<<2) + REG_VBR); -#else uint new_pc = m68ki_read_data_32(vector<<2); -#endif /* If vector is uninitialized, call the uninitialized interrupt vector */ if(new_pc == 0) - new_pc = m68ki_read_data_32((EXCEPTION_UNINITIALIZED_INTERRUPT<<2) + REG_VBR); + new_pc = m68ki_read_data_32((EXCEPTION_UNINITIALIZED_INTERRUPT<<2)); /* Generate a stack frame */ - m68ki_stack_frame_0000(REG_PC, sr, vector); -#if M68K_EMULATE_040 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_010 - if(FLAG_M && CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Create throwaway frame */ - m68ki_set_sm_flag(FLAG_S); /* clear M */ - sr |= 0x2000; /* Same as SR in master stack frame except S is forced high */ - m68ki_stack_frame_0001(REG_PC, sr, vector); - } -#endif + m68ki_stack_frame_3word(REG_PC, sr); m68ki_jump(new_pc); @@ -2059,6 +1567,7 @@ INLINE void m68ki_check_interrupts(void) m68ki_exception_interrupt(CPU_INT_LEVEL>>8); } +#endif /* _MEM68K_H_ */ /* ======================================================================== */ diff --git a/source/m68k/m68kops.c b/source/m68k/m68kops.c deleted file mode 100644 index 74ef69f..0000000 --- a/source/m68k/m68kops.c +++ /dev/null @@ -1,37084 +0,0 @@ -#include "m68kcpu.h" -#include "m68kCycleAccurate.h" - -extern void m68040_fpu_op0(void); -extern void m68040_fpu_op1(void); - -/* ======================================================================== */ -/* ========================= INSTRUCTION HANDLERS ========================= */ -/* ======================================================================== */ - - -static void m68k_op_1010(void) -{ - m68ki_exception_1010(); -} - - -static void m68k_op_1111(void) -{ - m68ki_exception_1111(); -} - - -#if M68K_EMULATE_040 -static void m68k_op_040fpu0_32(void) -{ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - m68040_fpu_op0(); - return; - } - m68ki_exception_1111(); -} - - -static void m68k_op_040fpu1_32(void) -{ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - m68040_fpu_op1(); - return; - } - m68ki_exception_1111(); -} -#endif - -static void m68k_op_abcd_8_rr(void) -{ - uint* r_dst = &DX; - uint src = DY; - uint dst = *r_dst; - uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); - - FLAG_V = ~res; /* Undefined V behavior */ - - if(res > 9) - res += 6; - res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); - FLAG_X = FLAG_C = (res > 0x99) << 8; - if(FLAG_C) - res -= 0xa0; - - FLAG_V &= res; /* Undefined V behavior part II */ - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; -} - - -static void m68k_op_abcd_8_mm_ax7(void) -{ - uint src = OPER_AY_PD_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); - - FLAG_V = ~res; /* Undefined V behavior */ - - if(res > 9) - res += 6; - res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); - FLAG_X = FLAG_C = (res > 0x99) << 8; - if(FLAG_C) - res -= 0xa0; - - FLAG_V &= res; /* Undefined V behavior part II */ - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_abcd_8_mm_ay7(void) -{ - uint src = OPER_A7_PD_8(); - uint ea = EA_AX_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); - - FLAG_V = ~res; /* Undefined V behavior */ - - if(res > 9) - res += 6; - res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); - FLAG_X = FLAG_C = (res > 0x99) << 8; - if(FLAG_C) - res -= 0xa0; - - FLAG_V &= res; /* Undefined V behavior part II */ - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_abcd_8_mm_axy7(void) -{ - uint src = OPER_A7_PD_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); - - FLAG_V = ~res; /* Undefined V behavior */ - - if(res > 9) - res += 6; - res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); - FLAG_X = FLAG_C = (res > 0x99) << 8; - if(FLAG_C) - res -= 0xa0; - - FLAG_V &= res; /* Undefined V behavior part II */ - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_abcd_8_mm(void) -{ - uint src = OPER_AY_PD_8(); - uint ea = EA_AX_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); - - FLAG_V = ~res; /* Undefined V behavior */ - - if(res > 9) - res += 6; - res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); - FLAG_X = FLAG_C = (res > 0x99) << 8; - if(FLAG_C) - res -= 0xa0; - - FLAG_V &= res; /* Undefined V behavior part II */ - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_add_8_er_d(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_8(DY); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_ai(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_AI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_pi(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_pi7(void) -{ - uint* r_dst = &DX; - uint src = OPER_A7_PI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_pd(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PD_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_pd7(void) -{ - uint* r_dst = &DX; - uint src = OPER_A7_PD_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_di(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_DI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_ix(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_IX_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_aw(void) -{ - uint* r_dst = &DX; - uint src = OPER_AW_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_al(void) -{ - uint* r_dst = &DX; - uint src = OPER_AL_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_pcdi(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCDI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_pcix(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCIX_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_8_er_i(void) -{ - uint* r_dst = &DX; - uint src = OPER_I_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_d(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_16(DY); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_a(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_16(AY); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_ai(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_AI_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_pi(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PI_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_pd(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PD_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_di(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_DI_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_ix(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_IX_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_aw(void) -{ - uint* r_dst = &DX; - uint src = OPER_AW_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_al(void) -{ - uint* r_dst = &DX; - uint src = OPER_AL_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_pcdi(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCDI_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_pcix(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCIX_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_16_er_i(void) -{ - uint* r_dst = &DX; - uint src = OPER_I_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_add_32_er_d(void) -{ - uint* r_dst = &DX; - uint src = DY; - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_a(void) -{ - uint* r_dst = &DX; - uint src = AY; - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_ai(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_AI_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_pi(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PI_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_pd(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PD_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_di(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_DI_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_ix(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_IX_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_aw(void) -{ - uint* r_dst = &DX; - uint src = OPER_AW_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_al(void) -{ - uint* r_dst = &DX; - uint src = OPER_AL_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_pcdi(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCDI_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_pcix(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCIX_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_32_er_i(void) -{ - uint* r_dst = &DX; - uint src = OPER_I_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_add_8_re_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_8_re_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_8_re_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_8_re_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_8_re_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_8_re_di(void) -{ - uint ea = EA_AY_DI_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_8_re_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_8_re_aw(void) -{ - uint ea = EA_AW_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_8_re_al(void) -{ - uint ea = EA_AL_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_add_16_re_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_add_16_re_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_add_16_re_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_add_16_re_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_add_16_re_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_add_16_re_aw(void) -{ - uint ea = EA_AW_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_add_16_re_al(void) -{ - uint ea = EA_AL_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_add_32_re_ai(void) -{ - uint ea = EA_AY_AI_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_add_32_re_pi(void) -{ - uint ea = EA_AY_PI_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_add_32_re_pd(void) -{ - uint ea = EA_AY_PD_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_add_32_re_di(void) -{ - uint ea = EA_AY_DI_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_add_32_re_ix(void) -{ - uint ea = EA_AY_IX_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_add_32_re_aw(void) -{ - uint ea = EA_AW_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_add_32_re_al(void) -{ - uint ea = EA_AL_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_adda_16_d(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(DY)); -} - - -static void m68k_op_adda_16_a(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(AY)); -} - - -static void m68k_op_adda_16_ai(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_AI_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_pi(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_PI_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_pd(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_PD_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_di(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_DI_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_ix(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_IX_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_aw(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AW_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_al(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AL_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_pcdi(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_PCDI_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_pcix(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_PCIX_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_16_i(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_I_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); -} - - -static void m68k_op_adda_32_d(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + DY); -} - - -static void m68k_op_adda_32_a(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + AY); -} - - -static void m68k_op_adda_32_ai(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_AY_AI_32() + *r_dst); -} - - -static void m68k_op_adda_32_pi(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_AY_PI_32() + *r_dst); -} - - -static void m68k_op_adda_32_pd(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_AY_PD_32() + *r_dst); -} - - -static void m68k_op_adda_32_di(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_AY_DI_32() + *r_dst); -} - - -static void m68k_op_adda_32_ix(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_AY_IX_32() + *r_dst); -} - - -static void m68k_op_adda_32_aw(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_AW_32() + *r_dst); -} - - -static void m68k_op_adda_32_al(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_AL_32() + *r_dst); -} - - -static void m68k_op_adda_32_pcdi(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_PCDI_32() + *r_dst); -} - - -static void m68k_op_adda_32_pcix(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_PCIX_32() + *r_dst); -} - - -static void m68k_op_adda_32_i(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(OPER_I_32() + *r_dst); -} - - -static void m68k_op_addi_8_d(void) -{ - uint* r_dst = &DY; - uint src = OPER_I_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_addi_8_ai(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_AI_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_8_pi(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_8_pi7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_8_pd(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_8_pd7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_8_di(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_DI_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_8_ix(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_IX_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_8_aw(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AW_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_8_al(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AL_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addi_16_d(void) -{ - uint* r_dst = &DY; - uint src = OPER_I_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_addi_16_ai(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_AI_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addi_16_pi(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PI_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addi_16_pd(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PD_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addi_16_di(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_DI_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addi_16_ix(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_IX_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addi_16_aw(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AW_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addi_16_al(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AL_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addi_32_d(void) -{ - uint* r_dst = &DY; - uint src = OPER_I_32(); - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_addi_32_ai(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_AI_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addi_32_pi(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PI_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addi_32_pd(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PD_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addi_32_di(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_DI_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addi_32_ix(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_IX_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addi_32_aw(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AW_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addi_32_al(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AL_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_d(void) -{ - uint* r_dst = &DY; - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_addq_8_ai(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_AI_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_pi(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_pi7(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_A7_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_pd(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_pd7(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_di(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_DI_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_ix(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_IX_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_aw(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AW_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_8_al(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AL_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst; - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_addq_16_d(void) -{ - uint* r_dst = &DY; - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_addq_16_a(void) -{ - uint* r_dst = &AY; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + (((REG_IR >> 9) - 1) & 7) + 1); -} - - -static void m68k_op_addq_16_ai(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_AI_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addq_16_pi(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PI_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addq_16_pd(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PD_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addq_16_di(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_DI_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addq_16_ix(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_IX_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addq_16_aw(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AW_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addq_16_al(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AL_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst; - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_addq_32_d(void) -{ - uint* r_dst = &DY; - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint dst = *r_dst; - uint res = src + dst; - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_addq_32_a(void) -{ - uint* r_dst = &AY; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst + (((REG_IR >> 9) - 1) & 7) + 1); -} - - -static void m68k_op_addq_32_ai(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_AI_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addq_32_pi(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PI_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addq_32_pd(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PD_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addq_32_di(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_DI_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addq_32_ix(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_IX_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addq_32_aw(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AW_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addq_32_al(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AL_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst; - - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_addx_8_rr(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_8(DY); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; -} - - -static void m68k_op_addx_16_rr(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_16(DY); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; -} - - -static void m68k_op_addx_32_rr(void) -{ - uint* r_dst = &DX; - uint src = DY; - uint dst = *r_dst; - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - *r_dst = res; -} - - -static void m68k_op_addx_8_mm_ax7(void) -{ - uint src = OPER_AY_PD_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_addx_8_mm_ay7(void) -{ - uint src = OPER_A7_PD_8(); - uint ea = EA_AX_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_addx_8_mm_axy7(void) -{ - uint src = OPER_A7_PD_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_addx_8_mm(void) -{ - uint src = OPER_AY_PD_8(); - uint ea = EA_AX_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_V = VFLAG_ADD_8(src, dst, res); - FLAG_X = FLAG_C = CFLAG_8(res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_addx_16_mm(void) -{ - uint src = OPER_AY_PD_16(); - uint ea = EA_AX_PD_16(); - uint dst = m68ki_read_16(ea); - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_V = VFLAG_ADD_16(src, dst, res); - FLAG_X = FLAG_C = CFLAG_16(res); - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_addx_32_mm(void) -{ - uint src = OPER_AY_PD_32(); - uint ea = EA_AX_PD_32(); - uint dst = m68ki_read_32(ea); - uint res = src + dst + XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_ADD_32(src, dst, res); - FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_and_8_er_d(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (DY | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_ai(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_AI_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_pi(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_PI_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_pi7(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_A7_PI_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_pd(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_PD_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_pd7(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_A7_PD_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_di(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_DI_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_ix(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_IX_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_aw(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AW_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_al(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AL_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_pcdi(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_PCDI_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_pcix(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_PCIX_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_er_i(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_I_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_d(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (DY | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_ai(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_AI_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_pi(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_PI_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_pd(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_PD_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_di(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_DI_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_ix(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_IX_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_aw(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AW_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_al(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AL_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_pcdi(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_PCDI_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_pcix(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_PCIX_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_16_er_i(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_I_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_d(void) -{ - FLAG_Z = DX &= DY; - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_ai(void) -{ - FLAG_Z = DX &= OPER_AY_AI_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_pi(void) -{ - FLAG_Z = DX &= OPER_AY_PI_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_pd(void) -{ - FLAG_Z = DX &= OPER_AY_PD_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_di(void) -{ - FLAG_Z = DX &= OPER_AY_DI_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_ix(void) -{ - FLAG_Z = DX &= OPER_AY_IX_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_aw(void) -{ - FLAG_Z = DX &= OPER_AW_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_al(void) -{ - FLAG_Z = DX &= OPER_AL_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_pcdi(void) -{ - FLAG_Z = DX &= OPER_PCDI_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_pcix(void) -{ - FLAG_Z = DX &= OPER_PCIX_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_32_er_i(void) -{ - FLAG_Z = DX &= OPER_I_32(); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_and_8_re_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_8_re_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_8_re_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_8_re_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_8_re_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_8_re_di(void) -{ - uint ea = EA_AY_DI_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_8_re_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_8_re_aw(void) -{ - uint ea = EA_AW_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_8_re_al(void) -{ - uint ea = EA_AL_8(); - uint res = DX & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_and_16_re_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint res = DX & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_and_16_re_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint res = DX & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_and_16_re_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint res = DX & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_and_16_re_di(void) -{ - uint ea = EA_AY_DI_16(); - uint res = DX & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_and_16_re_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint res = DX & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_and_16_re_aw(void) -{ - uint ea = EA_AW_16(); - uint res = DX & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_and_16_re_al(void) -{ - uint ea = EA_AL_16(); - uint res = DX & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_and_32_re_ai(void) -{ - uint ea = EA_AY_AI_32(); - uint res = DX & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_and_32_re_pi(void) -{ - uint ea = EA_AY_PI_32(); - uint res = DX & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_and_32_re_pd(void) -{ - uint ea = EA_AY_PD_32(); - uint res = DX & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_and_32_re_di(void) -{ - uint ea = EA_AY_DI_32(); - uint res = DX & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_and_32_re_ix(void) -{ - uint ea = EA_AY_IX_32(); - uint res = DX & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_and_32_re_aw(void) -{ - uint ea = EA_AW_32(); - uint res = DX & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_and_32_re_al(void) -{ - uint ea = EA_AL_32(); - uint res = DX & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_andi_8_d(void) -{ - FLAG_Z = MASK_OUT_ABOVE_8(DY &= (OPER_I_8() | 0xffffff00)); - - FLAG_N = NFLAG_8(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_andi_8_ai(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_AI_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_8_pi(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PI_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_8_pi7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PI_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_8_pd(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PD_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_8_pd7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PD_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_8_di(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_DI_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_8_ix(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_IX_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_8_aw(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AW_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_8_al(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AL_8(); - uint res = src & m68ki_read_8(ea); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_andi_16_d(void) -{ - FLAG_Z = MASK_OUT_ABOVE_16(DY &= (OPER_I_16() | 0xffff0000)); - - FLAG_N = NFLAG_16(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_andi_16_ai(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_AI_16(); - uint res = src & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_andi_16_pi(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PI_16(); - uint res = src & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_andi_16_pd(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PD_16(); - uint res = src & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_andi_16_di(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_DI_16(); - uint res = src & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_andi_16_ix(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_IX_16(); - uint res = src & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_andi_16_aw(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AW_16(); - uint res = src & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_andi_16_al(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AL_16(); - uint res = src & m68ki_read_16(ea); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_andi_32_d(void) -{ - FLAG_Z = DY &= (OPER_I_32()); - - FLAG_N = NFLAG_32(FLAG_Z); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_andi_32_ai(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_AI_32(); - uint res = src & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_andi_32_pi(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PI_32(); - uint res = src & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_andi_32_pd(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PD_32(); - uint res = src & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_andi_32_di(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_DI_32(); - uint res = src & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_andi_32_ix(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_IX_32(); - uint res = src & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_andi_32_aw(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AW_32(); - uint res = src & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_andi_32_al(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AL_32(); - uint res = src & m68ki_read_32(ea); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_andi_16_toc(void) -{ - m68ki_set_ccr(m68ki_get_ccr() & OPER_I_16()); -} - - -static void m68k_op_andi_16_tos(void) -{ - if(FLAG_S) - { - uint src = OPER_I_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(m68ki_get_sr() & src); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_asr_8_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = src >> shift; - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - if(GET_MSB_8(src)) - res |= m68ki_shift_8_table[shift]; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_X = FLAG_C = src << (9-shift); -} - - -static void m68k_op_asr_16_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = src >> shift; - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - if(GET_MSB_16(src)) - res |= m68ki_shift_16_table[shift]; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_X = FLAG_C = src << (9-shift); -} - - -static void m68k_op_asr_32_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = *r_dst; - uint res = src >> shift; - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - if(GET_MSB_32(src)) - res |= m68ki_shift_32_table[shift]; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_X = FLAG_C = src << (9-shift); -} - - -static void m68k_op_asr_8_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = src >> shift; - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift < 8) - { - if(GET_MSB_8(src)) - res |= m68ki_shift_8_table[shift]; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_X = FLAG_C = src << (9-shift); - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - if(GET_MSB_8(src)) - { - *r_dst |= 0xff; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst &= 0xffffff00; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_8(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_asr_16_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = src >> shift; - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift < 16) - { - if(GET_MSB_16(src)) - res |= m68ki_shift_16_table[shift]; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_C = FLAG_X = (src >> (shift - 1))<<8; - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - if(GET_MSB_16(src)) - { - *r_dst |= 0xffff; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst &= 0xffff0000; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_16(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_asr_32_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = *r_dst; - uint res = src >> shift; - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift < 32) - { - if(GET_MSB_32(src)) - res |= m68ki_shift_32_table[shift]; - - *r_dst = res; - - FLAG_C = FLAG_X = (src >> (shift - 1))<<8; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - if(GET_MSB_32(src)) - { - *r_dst = 0xffffffff; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst = 0; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_32(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_asr_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - if(GET_MSB_16(src)) - res |= 0x8000; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = FLAG_X = src << 8; -} - - -static void m68k_op_asr_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - if(GET_MSB_16(src)) - res |= 0x8000; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = FLAG_X = src << 8; -} - - -static void m68k_op_asr_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - if(GET_MSB_16(src)) - res |= 0x8000; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = FLAG_X = src << 8; -} - - -static void m68k_op_asr_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - if(GET_MSB_16(src)) - res |= 0x8000; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = FLAG_X = src << 8; -} - - -static void m68k_op_asr_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - if(GET_MSB_16(src)) - res |= 0x8000; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = FLAG_X = src << 8; -} - - -static void m68k_op_asr_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - if(GET_MSB_16(src)) - res |= 0x8000; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = FLAG_X = src << 8; -} - - -static void m68k_op_asr_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - if(GET_MSB_16(src)) - res |= 0x8000; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = FLAG_X = src << 8; -} - - -static void m68k_op_asl_8_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = MASK_OUT_ABOVE_8(src << shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_X = FLAG_C = src << shift; - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - src &= m68ki_shift_8_table[shift + 1]; - FLAG_V = (!(src == 0 || (src == m68ki_shift_8_table[shift + 1] && shift < 8)))<<7; -} - - -static void m68k_op_asl_16_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = MASK_OUT_ABOVE_16(src << shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> (8-shift); - src &= m68ki_shift_16_table[shift + 1]; - FLAG_V = (!(src == 0 || src == m68ki_shift_16_table[shift + 1]))<<7; -} - - -static void m68k_op_asl_32_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = *r_dst; - uint res = MASK_OUT_ABOVE_32(src << shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> (24-shift); - src &= m68ki_shift_32_table[shift + 1]; - FLAG_V = (!(src == 0 || src == m68ki_shift_32_table[shift + 1]))<<7; -} - - -static void m68k_op_asl_8_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = MASK_OUT_ABOVE_8(src << shift); - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift < 8) - { - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - FLAG_X = FLAG_C = src << shift; - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - src &= m68ki_shift_8_table[shift + 1]; - FLAG_V = (!(src == 0 || src == m68ki_shift_8_table[shift + 1]))<<7; - return; - } - - *r_dst &= 0xffffff00; - FLAG_X = FLAG_C = ((shift == 8 ? src & 1 : 0))<<8; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = (!(src == 0))<<7; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_8(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_asl_16_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = MASK_OUT_ABOVE_16(src << shift); - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift < 16) - { - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - FLAG_X = FLAG_C = (src << shift) >> 8; - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - src &= m68ki_shift_16_table[shift + 1]; - FLAG_V = (!(src == 0 || src == m68ki_shift_16_table[shift + 1]))<<7; - return; - } - - *r_dst &= 0xffff0000; - FLAG_X = FLAG_C = ((shift == 16 ? src & 1 : 0))<<8; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = (!(src == 0))<<7; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_16(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_asl_32_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = *r_dst; - uint res = MASK_OUT_ABOVE_32(src << shift); - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift < 32) - { - *r_dst = res; - FLAG_X = FLAG_C = (src >> (32 - shift)) << 8; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - src &= m68ki_shift_32_table[shift + 1]; - FLAG_V = (!(src == 0 || src == m68ki_shift_32_table[shift + 1]))<<7; - return; - } - - *r_dst = 0; - FLAG_X = FLAG_C = ((shift == 32 ? src & 1 : 0))<<8; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = (!(src == 0))<<7; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_32(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_asl_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - src &= 0xc000; - FLAG_V = (!(src == 0 || src == 0xc000))<<7; -} - - -static void m68k_op_asl_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - src &= 0xc000; - FLAG_V = (!(src == 0 || src == 0xc000))<<7; -} - - -static void m68k_op_asl_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - src &= 0xc000; - FLAG_V = (!(src == 0 || src == 0xc000))<<7; -} - - -static void m68k_op_asl_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - src &= 0xc000; - FLAG_V = (!(src == 0 || src == 0xc000))<<7; -} - - -static void m68k_op_asl_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - src &= 0xc000; - FLAG_V = (!(src == 0 || src == 0xc000))<<7; -} - - -static void m68k_op_asl_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - src &= 0xc000; - FLAG_V = (!(src == 0 || src == 0xc000))<<7; -} - - -static void m68k_op_asl_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - src &= 0xc000; - FLAG_V = (!(src == 0 || src == 0xc000))<<7; -} - - -static void m68k_op_bhi_8(void) -{ - if(COND_HI()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bls_8(void) -{ - if(COND_LS()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bcc_8(void) -{ - if(COND_CC()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bcs_8(void) -{ - if(COND_CS()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bne_8(void) -{ - if(COND_NE()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_beq_8(void) -{ - if(COND_EQ()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bvc_8(void) -{ - if(COND_VC()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bvs_8(void) -{ - if(COND_VS()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bpl_8(void) -{ - if(COND_PL()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bmi_8(void) -{ - if(COND_MI()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bge_8(void) -{ - if(COND_GE()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_blt_8(void) -{ - if(COND_LT()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bgt_8(void) -{ - if(COND_GT()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_ble_8(void) -{ - if(COND_LE()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); -} - - -static void m68k_op_bhi_16(void) -{ - if(COND_HI()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bls_16(void) -{ - if(COND_LS()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bcc_16(void) -{ - if(COND_CC()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bcs_16(void) -{ - if(COND_CS()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bne_16(void) -{ - if(COND_NE()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_beq_16(void) -{ - if(COND_EQ()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bvc_16(void) -{ - if(COND_VC()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bvs_16(void) -{ - if(COND_VS()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bpl_16(void) -{ - if(COND_PL()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bmi_16(void) -{ - if(COND_MI()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bge_16(void) -{ - if(COND_GE()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_blt_16(void) -{ - if(COND_LT()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bgt_16(void) -{ - if(COND_GT()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_ble_16(void) -{ - if(COND_LE()) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_BCC_NOTAKE_W); -} - - -static void m68k_op_bhi_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_HI()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_HI()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bls_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LS()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_LS()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bcc_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_CC()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_CC()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bcs_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_CS()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_CS()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bne_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_NE()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_NE()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_beq_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_EQ()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_EQ()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bvc_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_VC()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_VC()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bvs_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_VS()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_VS()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bpl_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_PL()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_PL()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bmi_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_MI()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_MI()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bge_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_GE()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_GE()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_blt_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LT()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_LT()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bgt_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_GT()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_GT()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_ble_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LE()) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - return; - } - REG_PC += 4; - return; - } - else - { - if(COND_LE()) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - return; - } - USE_CYCLES(CYC_BCC_NOTAKE_B); - } -} - - -static void m68k_op_bchg_32_r_d(void) -{ - uint* r_dst = &DY; - uint mask = 1 << (DX & 0x1f); - - FLAG_Z = *r_dst & mask; - *r_dst ^= mask; -} - - -static void m68k_op_bchg_8_r_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_r_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_r_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_r_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_r_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_r_di(void) -{ - uint ea = EA_AY_DI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_r_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_r_aw(void) -{ - uint ea = EA_AW_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_r_al(void) -{ - uint ea = EA_AL_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_32_s_d(void) -{ - uint* r_dst = &DY; - uint mask = 1 << (OPER_I_8() & 0x1f); - - FLAG_Z = *r_dst & mask; - *r_dst ^= mask; -} - - -static void m68k_op_bchg_8_s_ai(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_AI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_s_pi(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_PI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_s_pi7(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_A7_PI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_s_pd(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_PD_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_s_pd7(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_A7_PD_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_s_di(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_DI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_s_ix(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_IX_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_s_aw(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AW_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bchg_8_s_al(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AL_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src ^ mask); -} - - -static void m68k_op_bclr_32_r_d(void) -{ - uint* r_dst = &DY; - uint mask = 1 << (DX & 0x1f); - - FLAG_Z = *r_dst & mask; - *r_dst &= ~mask; -} - - -static void m68k_op_bclr_8_r_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_r_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_r_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_r_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_r_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_r_di(void) -{ - uint ea = EA_AY_DI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_r_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_r_aw(void) -{ - uint ea = EA_AW_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_r_al(void) -{ - uint ea = EA_AL_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_32_s_d(void) -{ - uint* r_dst = &DY; - uint mask = 1 << (OPER_I_8() & 0x1f); - - FLAG_Z = *r_dst & mask; - *r_dst &= ~mask; -} - - -static void m68k_op_bclr_8_s_ai(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_AI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_s_pi(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_PI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_s_pi7(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_A7_PI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_s_pd(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_PD_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_s_pd7(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_A7_PD_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_s_di(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_DI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_s_ix(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_IX_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_s_aw(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AW_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -static void m68k_op_bclr_8_s_al(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AL_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src & ~mask); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_bfchg_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint offset = (word2>>6)&31; - uint width = word2; - uint* data = &DY; - uint64 mask; - - - if(BIT_B(word2)) - offset = REG_D[offset&7]; - if(BIT_5(word2)) - width = REG_D[width&7]; - - offset &= 31; - width = ((width-1) & 31) + 1; - - mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask = ROR_32(mask, offset); - - FLAG_N = NFLAG_32(*data<>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_AI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long ^ mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte ^ mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfchg_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_DI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long ^ mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte ^ mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfchg_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_IX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long ^ mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte ^ mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfchg_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AW_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long ^ mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte ^ mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfchg_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AL_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long ^ mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte ^ mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfclr_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint offset = (word2>>6)&31; - uint width = word2; - uint* data = &DY; - uint64 mask; - - - if(BIT_B(word2)) - offset = REG_D[offset&7]; - if(BIT_5(word2)) - width = REG_D[width&7]; - - - offset &= 31; - width = ((width-1) & 31) + 1; - - - mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask = ROR_32(mask, offset); - - FLAG_N = NFLAG_32(*data<>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_AI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long & ~mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte & ~mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfclr_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_DI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long & ~mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte & ~mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfclr_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_IX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long & ~mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte & ~mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfclr_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AW_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long & ~mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte & ~mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfclr_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AL_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long & ~mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte & ~mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfexts_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint offset = (word2>>6)&31; - uint width = word2; - uint64 data = DY; - - - if(BIT_B(word2)) - offset = REG_D[offset&7]; - if(BIT_5(word2)) - width = REG_D[width&7]; - - offset &= 31; - width = ((width-1) & 31) + 1; - - data = ROL_32(data, offset); - FLAG_N = NFLAG_32(data); - data = MAKE_INT_32(data) >> (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2>>12)&7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfexts_32_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AY_AI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data = MAKE_INT_32(data) >> (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfexts_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AY_DI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data = MAKE_INT_32(data) >> (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfexts_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AY_IX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data = MAKE_INT_32(data) >> (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfexts_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AW_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data = MAKE_INT_32(data) >> (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfexts_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AL_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data = MAKE_INT_32(data) >> (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfexts_32_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_PCDI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data = MAKE_INT_32(data) >> (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfexts_32_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_PCIX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data = MAKE_INT_32(data) >> (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfextu_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint offset = (word2>>6)&31; - uint width = word2; - uint64 data = DY; - - - if(BIT_B(word2)) - offset = REG_D[offset&7]; - if(BIT_5(word2)) - width = REG_D[width&7]; - - offset &= 31; - width = ((width-1) & 31) + 1; - - data = ROL_32(data, offset); - FLAG_N = NFLAG_32(data); - data >>= 32 - width; - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2>>12)&7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfextu_32_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AY_AI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfextu_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AY_DI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfextu_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AY_IX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfextu_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AW_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfextu_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_AL_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfextu_32_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_PCDI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfextu_32_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint data; - uint ea = EA_PCIX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - REG_D[(word2 >> 12) & 7] = data; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfffo_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint offset = (word2>>6)&31; - uint width = word2; - uint64 data = DY; - uint bit; - - - if(BIT_B(word2)) - offset = REG_D[offset&7]; - if(BIT_5(word2)) - width = REG_D[width&7]; - - offset &= 31; - width = ((width-1) & 31) + 1; - - data = ROL_32(data, offset); - FLAG_N = NFLAG_32(data); - data >>= 32 - width; - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) - offset++; - - REG_D[(word2>>12)&7] = offset; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfffo_32_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - sint local_offset; - uint width = word2; - uint data; - uint bit; - uint ea = EA_AY_AI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - local_offset = offset % 8; - if(local_offset < 0) - { - local_offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << local_offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) - offset++; - - REG_D[(word2>>12)&7] = offset; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfffo_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - sint local_offset; - uint width = word2; - uint data; - uint bit; - uint ea = EA_AY_DI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - local_offset = offset % 8; - if(local_offset < 0) - { - local_offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << local_offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) - offset++; - - REG_D[(word2>>12)&7] = offset; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfffo_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - sint local_offset; - uint width = word2; - uint data; - uint bit; - uint ea = EA_AY_IX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - local_offset = offset % 8; - if(local_offset < 0) - { - local_offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << local_offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) - offset++; - - REG_D[(word2>>12)&7] = offset; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfffo_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - sint local_offset; - uint width = word2; - uint data; - uint bit; - uint ea = EA_AW_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - local_offset = offset % 8; - if(local_offset < 0) - { - local_offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << local_offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) - offset++; - - REG_D[(word2>>12)&7] = offset; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfffo_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - sint local_offset; - uint width = word2; - uint data; - uint bit; - uint ea = EA_AL_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - local_offset = offset % 8; - if(local_offset < 0) - { - local_offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << local_offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) - offset++; - - REG_D[(word2>>12)&7] = offset; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfffo_32_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - sint local_offset; - uint width = word2; - uint data; - uint bit; - uint ea = EA_PCDI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - local_offset = offset % 8; - if(local_offset < 0) - { - local_offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << local_offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) - offset++; - - REG_D[(word2>>12)&7] = offset; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfffo_32_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - sint local_offset; - uint width = word2; - uint data; - uint bit; - uint ea = EA_PCIX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - local_offset = offset % 8; - if(local_offset < 0) - { - local_offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - data = m68ki_read_32(ea); - data = MASK_OUT_ABOVE_32(data< 32) - data |= (m68ki_read_8(ea+4) << local_offset) >> 8; - - FLAG_N = NFLAG_32(data); - data >>= (32 - width); - - FLAG_Z = data; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - for(bit = 1<<(width-1);bit && !(data & bit);bit>>= 1) - offset++; - - REG_D[(word2>>12)&7] = offset; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfins_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint offset = (word2>>6)&31; - uint width = word2; - uint* data = &DY; - uint64 mask; - uint64 insert = REG_D[(word2>>12)&7]; - - - if(BIT_B(word2)) - offset = REG_D[offset&7]; - if(BIT_5(word2)) - width = REG_D[width&7]; - - - offset &= 31; - width = ((width-1) & 31) + 1; - - - mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask = ROR_32(mask, offset); - - insert = MASK_OUT_ABOVE_32(insert << (32 - width)); - FLAG_N = NFLAG_32(insert); - FLAG_Z = insert; - insert = ROR_32(insert, offset); - - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - *data &= ~mask; - *data |= insert; - - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfins_32_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint insert_base = REG_D[(word2>>12)&7]; - uint insert_long; - uint insert_byte; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_AI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); - FLAG_N = NFLAG_32(insert_base); - FLAG_Z = insert_base; - insert_long = insert_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - insert_byte = MASK_OUT_ABOVE_8(insert_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfins_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint insert_base = REG_D[(word2>>12)&7]; - uint insert_long; - uint insert_byte; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_DI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); - FLAG_N = NFLAG_32(insert_base); - FLAG_Z = insert_base; - insert_long = insert_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - insert_byte = MASK_OUT_ABOVE_8(insert_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfins_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint insert_base = REG_D[(word2>>12)&7]; - uint insert_long; - uint insert_byte; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_IX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); - FLAG_N = NFLAG_32(insert_base); - FLAG_Z = insert_base; - insert_long = insert_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - insert_byte = MASK_OUT_ABOVE_8(insert_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfins_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint insert_base = REG_D[(word2>>12)&7]; - uint insert_long; - uint insert_byte; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AW_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); - FLAG_N = NFLAG_32(insert_base); - FLAG_Z = insert_base; - insert_long = insert_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - insert_byte = MASK_OUT_ABOVE_8(insert_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfins_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint insert_base = REG_D[(word2>>12)&7]; - uint insert_long; - uint insert_byte; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AL_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - insert_base = MASK_OUT_ABOVE_32(insert_base << (32 - width)); - FLAG_N = NFLAG_32(insert_base); - FLAG_Z = insert_base; - insert_long = insert_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, (data_long & ~mask_long) | insert_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - insert_byte = MASK_OUT_ABOVE_8(insert_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, (data_byte & ~mask_byte) | insert_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfset_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint offset = (word2>>6)&31; - uint width = word2; - uint* data = &DY; - uint64 mask; - - - if(BIT_B(word2)) - offset = REG_D[offset&7]; - if(BIT_5(word2)) - width = REG_D[width&7]; - - - offset &= 31; - width = ((width-1) & 31) + 1; - - - mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask = ROR_32(mask, offset); - - FLAG_N = NFLAG_32(*data<>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_AI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long | mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte | mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfset_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_DI_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long | mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte | mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfset_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_IX_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long | mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte | mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfset_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AW_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long | mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte | mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bfset_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AL_8(); - - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = NFLAG_32(data_long << offset); - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - m68ki_write_32(ea, data_long | mask_long); - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - m68ki_write_8(ea+4, data_byte | mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bftst_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint offset = (word2>>6)&31; - uint width = word2; - uint* data = &DY; - uint64 mask; - - - if(BIT_B(word2)) - offset = REG_D[offset&7]; - if(BIT_5(word2)) - width = REG_D[width&7]; - - - offset &= 31; - width = ((width-1) & 31) + 1; - - - mask = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask = ROR_32(mask, offset); - - FLAG_N = NFLAG_32(*data<>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_AI_8(); - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = ((data_long & (0x80000000 >> offset))<>24; - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bftst_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_DI_8(); - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = ((data_long & (0x80000000 >> offset))<>24; - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bftst_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AY_IX_8(); - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = ((data_long & (0x80000000 >> offset))<>24; - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bftst_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AW_8(); - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = ((data_long & (0x80000000 >> offset))<>24; - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bftst_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_AL_8(); - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = ((data_long & (0x80000000 >> offset))<>24; - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bftst_32_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_PCDI_8(); - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = ((data_long & (0x80000000 >> offset))<>24; - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_bftst_32_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - sint offset = (word2>>6)&31; - uint width = word2; - uint mask_base; - uint data_long; - uint mask_long; - uint data_byte = 0; - uint mask_byte = 0; - uint ea = EA_PCIX_8(); - - if(BIT_B(word2)) - offset = MAKE_INT_32(REG_D[offset&7]); - if(BIT_5(word2)) - width = REG_D[width&7]; - - /* Offset is signed so we have to use ugly math =( */ - ea += offset / 8; - offset %= 8; - if(offset < 0) - { - offset += 8; - ea--; - } - width = ((width-1) & 31) + 1; - - - mask_base = MASK_OUT_ABOVE_32(0xffffffff << (32 - width)); - mask_long = mask_base >> offset; - - data_long = m68ki_read_32(ea); - FLAG_N = ((data_long & (0x80000000 >> offset))<>24; - FLAG_Z = data_long & mask_long; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - if((width + offset) > 32) - { - mask_byte = MASK_OUT_ABOVE_8(mask_base); - data_byte = m68ki_read_8(ea+4); - FLAG_Z |= (data_byte & mask_byte); - } - return; - } - m68ki_exception_illegal(); -} -#endif - - -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_bkpt(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - m68ki_bkpt_ack(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE) ? REG_IR & 7 : 0); /* auto-disable (see m68kcpu.h) */ - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_bra_8(void) -{ - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_bra_16(void) -{ - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_bra_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint offset = OPER_I_32(); - REG_PC -= 4; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_32(offset); - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ - return; - } - else - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ - } -} - - -static void m68k_op_bset_32_r_d(void) -{ - uint* r_dst = &DY; - uint mask = 1 << (DX & 0x1f); - - FLAG_Z = *r_dst & mask; - *r_dst |= mask; -} - - -static void m68k_op_bset_8_r_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_r_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_r_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_r_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_r_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_r_di(void) -{ - uint ea = EA_AY_DI_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_r_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_r_aw(void) -{ - uint ea = EA_AW_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_r_al(void) -{ - uint ea = EA_AL_8(); - uint src = m68ki_read_8(ea); - uint mask = 1 << (DX & 7); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_32_s_d(void) -{ - uint* r_dst = &DY; - uint mask = 1 << (OPER_I_8() & 0x1f); - - FLAG_Z = *r_dst & mask; - *r_dst |= mask; -} - - -static void m68k_op_bset_8_s_ai(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_AI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_s_pi(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_PI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_s_pi7(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_A7_PI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_s_pd(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_PD_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_s_pd7(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_A7_PD_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_s_di(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_DI_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_s_ix(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AY_IX_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_s_aw(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AW_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bset_8_s_al(void) -{ - uint mask = 1 << (OPER_I_8() & 7); - uint ea = EA_AL_8(); - uint src = m68ki_read_8(ea); - - FLAG_Z = src & mask; - m68ki_write_8(ea, src | mask); -} - - -static void m68k_op_bsr_8(void) -{ - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); -} - - -static void m68k_op_bsr_16(void) -{ - uint offset = OPER_I_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - REG_PC -= 2; - m68ki_branch_16(offset); -} - - -static void m68k_op_bsr_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint offset = OPER_I_32(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - REG_PC -= 4; - m68ki_branch_32(offset); - return; - } - else - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); - } -} - - -static void m68k_op_btst_32_r_d(void) -{ - FLAG_Z = DY & (1 << (DX & 0x1f)); -} - - -static void m68k_op_btst_8_r_ai(void) -{ - FLAG_Z = OPER_AY_AI_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_pi(void) -{ - FLAG_Z = OPER_AY_PI_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_pi7(void) -{ - FLAG_Z = OPER_A7_PI_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_pd(void) -{ - FLAG_Z = OPER_AY_PD_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_pd7(void) -{ - FLAG_Z = OPER_A7_PD_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_di(void) -{ - FLAG_Z = OPER_AY_DI_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_ix(void) -{ - FLAG_Z = OPER_AY_IX_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_aw(void) -{ - FLAG_Z = OPER_AW_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_al(void) -{ - FLAG_Z = OPER_AL_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_pcdi(void) -{ - FLAG_Z = OPER_PCDI_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_pcix(void) -{ - FLAG_Z = OPER_PCIX_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_8_r_i(void) -{ - FLAG_Z = OPER_I_8() & (1 << (DX & 7)); -} - - -static void m68k_op_btst_32_s_d(void) -{ - FLAG_Z = DY & (1 << (OPER_I_8() & 0x1f)); -} - - -static void m68k_op_btst_8_s_ai(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_AY_AI_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_pi(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_AY_PI_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_pi7(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_A7_PI_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_pd(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_AY_PD_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_pd7(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_A7_PD_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_di(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_AY_DI_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_ix(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_AY_IX_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_aw(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_AW_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_al(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_AL_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_pcdi(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_PCDI_8() & (1 << bit); -} - - -static void m68k_op_btst_8_s_pcix(void) -{ - uint bit = OPER_I_8() & 7; - - FLAG_Z = OPER_PCIX_8() & (1 << bit); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_callm_32_ai(void) -{ - /* note: watch out for pcrelative modes */ - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - { - uint ea = EA_AY_AI_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_PC += 2; -(void)ea; /* just to avoid an 'unused variable' warning */ - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_callm_32_di(void) -{ - /* note: watch out for pcrelative modes */ - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - { - uint ea = EA_AY_DI_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_PC += 2; -(void)ea; /* just to avoid an 'unused variable' warning */ - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_callm_32_ix(void) -{ - /* note: watch out for pcrelative modes */ - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - { - uint ea = EA_AY_IX_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_PC += 2; -(void)ea; /* just to avoid an 'unused variable' warning */ - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_callm_32_aw(void) -{ - /* note: watch out for pcrelative modes */ - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - { - uint ea = EA_AW_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_PC += 2; -(void)ea; /* just to avoid an 'unused variable' warning */ - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_callm_32_al(void) -{ - /* note: watch out for pcrelative modes */ - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - { - uint ea = EA_AL_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_PC += 2; -(void)ea; /* just to avoid an 'unused variable' warning */ - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_callm_32_pcdi(void) -{ - /* note: watch out for pcrelative modes */ - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - { - uint ea = EA_PCDI_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_PC += 2; -(void)ea; /* just to avoid an 'unused variable' warning */ - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_callm_32_pcix(void) -{ - /* note: watch out for pcrelative modes */ - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - { - uint ea = EA_PCIX_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_PC += 2; -(void)ea; /* just to avoid an 'unused variable' warning */ - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_AI_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_pi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PI_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_pi7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_A7_PI_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_pd(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PD_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_pd7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_A7_PD_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_DI_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_IX_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AW_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_8_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AL_8(); - uint dest = m68ki_read_8(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_8(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(*compare, dest, res); - FLAG_C = CFLAG_8(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_8(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_8(ea, MASK_OUT_ABOVE_8(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_16_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_AI_16(); - uint dest = m68ki_read_16(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_16(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(*compare, dest, res); - FLAG_C = CFLAG_16(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_16(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_16_pi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PI_16(); - uint dest = m68ki_read_16(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_16(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(*compare, dest, res); - FLAG_C = CFLAG_16(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_16(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_16_pd(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PD_16(); - uint dest = m68ki_read_16(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_16(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(*compare, dest, res); - FLAG_C = CFLAG_16(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_16(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_16_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_DI_16(); - uint dest = m68ki_read_16(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_16(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(*compare, dest, res); - FLAG_C = CFLAG_16(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_16(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_16_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_IX_16(); - uint dest = m68ki_read_16(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_16(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(*compare, dest, res); - FLAG_C = CFLAG_16(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_16(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_16_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AW_16(); - uint dest = m68ki_read_16(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_16(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(*compare, dest, res); - FLAG_C = CFLAG_16(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_16(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_16_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AL_16(); - uint dest = m68ki_read_16(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - MASK_OUT_ABOVE_16(*compare); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(*compare, dest, res); - FLAG_C = CFLAG_16(res); - - if(COND_NE()) - *compare = MASK_OUT_BELOW_16(*compare) | dest; - else - { - USE_CYCLES(21); - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_D[(word2 >> 6) & 7])); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_32_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_AI_32(); - uint dest = m68ki_read_32(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - *compare; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(*compare, dest, res); - FLAG_C = CFLAG_SUB_32(*compare, dest, res); - - if(COND_NE()) - *compare = dest; - else - { - USE_CYCLES(21); - m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_32_pi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PI_32(); - uint dest = m68ki_read_32(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - *compare; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(*compare, dest, res); - FLAG_C = CFLAG_SUB_32(*compare, dest, res); - - if(COND_NE()) - *compare = dest; - else - { - USE_CYCLES(21); - m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_32_pd(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PD_32(); - uint dest = m68ki_read_32(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - *compare; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(*compare, dest, res); - FLAG_C = CFLAG_SUB_32(*compare, dest, res); - - if(COND_NE()) - *compare = dest; - else - { - USE_CYCLES(21); - m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_DI_32(); - uint dest = m68ki_read_32(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - *compare; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(*compare, dest, res); - FLAG_C = CFLAG_SUB_32(*compare, dest, res); - - if(COND_NE()) - *compare = dest; - else - { - USE_CYCLES(21); - m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_IX_32(); - uint dest = m68ki_read_32(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - *compare; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(*compare, dest, res); - FLAG_C = CFLAG_SUB_32(*compare, dest, res); - - if(COND_NE()) - *compare = dest; - else - { - USE_CYCLES(21); - m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AW_32(); - uint dest = m68ki_read_32(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - *compare; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(*compare, dest, res); - FLAG_C = CFLAG_SUB_32(*compare, dest, res); - - if(COND_NE()) - *compare = dest; - else - { - USE_CYCLES(21); - m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint ea = EA_AL_32(); - uint dest = m68ki_read_32(ea); - uint* compare = ®_D[word2 & 7]; - uint res = dest - *compare; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(*compare, dest, res); - FLAG_C = CFLAG_SUB_32(*compare, dest, res); - - if(COND_NE()) - *compare = dest; - else - { - USE_CYCLES(21); - m68ki_write_32(ea, REG_D[(word2 >> 6) & 7]); - } - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas2_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_32(); - uint* compare1 = ®_D[(word2 >> 16) & 7]; - uint ea1 = REG_DA[(word2 >> 28) & 15]; - uint dest1 = m68ki_read_16(ea1); - uint res1 = dest1 - MASK_OUT_ABOVE_16(*compare1); - uint* compare2 = ®_D[word2 & 7]; - uint ea2 = REG_DA[(word2 >> 12) & 15]; - uint dest2 = m68ki_read_16(ea2); - uint res2; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_16(res1); - FLAG_Z = MASK_OUT_ABOVE_16(res1); - FLAG_V = VFLAG_SUB_16(*compare1, dest1, res1); - FLAG_C = CFLAG_16(res1); - - if(COND_EQ()) - { - res2 = dest2 - MASK_OUT_ABOVE_16(*compare2); - - FLAG_N = NFLAG_16(res2); - FLAG_Z = MASK_OUT_ABOVE_16(res2); - FLAG_V = VFLAG_SUB_16(*compare2, dest2, res2); - FLAG_C = CFLAG_16(res2); - - if(COND_EQ()) - { - USE_CYCLES(21); - m68ki_write_16(ea1, REG_D[(word2 >> 22) & 7]); - m68ki_write_16(ea2, REG_D[(word2 >> 6) & 7]); - return; - } - } - *compare1 = BIT_1F(word2) ? MAKE_INT_16(dest1) : MASK_OUT_BELOW_16(*compare1) | dest1; - *compare2 = BIT_F(word2) ? MAKE_INT_16(dest2) : MASK_OUT_BELOW_16(*compare2) | dest2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cas2_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_32(); - uint* compare1 = ®_D[(word2 >> 16) & 7]; - uint ea1 = REG_DA[(word2 >> 28) & 15]; - uint dest1 = m68ki_read_32(ea1); - uint res1 = dest1 - *compare1; - uint* compare2 = ®_D[word2 & 7]; - uint ea2 = REG_DA[(word2 >> 12) & 15]; - uint dest2 = m68ki_read_32(ea2); - uint res2; - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - FLAG_N = NFLAG_32(res1); - FLAG_Z = MASK_OUT_ABOVE_32(res1); - FLAG_V = VFLAG_SUB_32(*compare1, dest1, res1); - FLAG_C = CFLAG_SUB_32(*compare1, dest1, res1); - - if(COND_EQ()) - { - res2 = dest2 - *compare2; - - FLAG_N = NFLAG_32(res2); - FLAG_Z = MASK_OUT_ABOVE_32(res2); - FLAG_V = VFLAG_SUB_32(*compare2, dest2, res2); - FLAG_C = CFLAG_SUB_32(*compare2, dest2, res2); - - if(COND_EQ()) - { - USE_CYCLES(21); - m68ki_write_32(ea1, REG_D[(word2 >> 22) & 7]); - m68ki_write_32(ea2, REG_D[(word2 >> 6) & 7]); - return; - } - } - *compare1 = dest1; - *compare2 = dest2; - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_chk_16_d(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(DY); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_ai(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_AY_AI_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_pi(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_AY_PI_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_pd(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_AY_PD_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_di(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_AY_DI_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_ix(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_AY_IX_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_aw(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_AW_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_al(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_AL_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_pcdi(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_PCDI_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_pcix(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_PCIX_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -static void m68k_op_chk_16_i(void) -{ - sint src = MAKE_INT_16(DX); - sint bound = MAKE_INT_16(OPER_I_16()); - - FLAG_Z = ZFLAG_16(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_chk_32_d(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(DY); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_AY_AI_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_pi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_AY_PI_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_pd(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_AY_PD_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_AY_DI_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_AY_IX_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_AW_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_AL_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_PCDI_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_PCIX_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk_32_i(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - sint src = MAKE_INT_32(DX); - sint bound = MAKE_INT_32(OPER_I_32()); - - FLAG_Z = ZFLAG_32(src); /* Undocumented */ - FLAG_V = VFLAG_CLEAR; /* Undocumented */ - FLAG_C = CFLAG_CLEAR; /* Undocumented */ - - if(src >= 0 && src <= bound) - { - return; - } - FLAG_N = (src < 0)<<7; - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_8_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xff; - uint ea = EA_PCDI_8(); - uint lower_bound = m68ki_read_pcrel_8(ea); - uint upper_bound = m68ki_read_pcrel_8(ea + 1); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_8_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xff; - uint ea = EA_PCIX_8(); - uint lower_bound = m68ki_read_pcrel_8(ea); - uint upper_bound = m68ki_read_pcrel_8(ea + 1); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_8_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xff; - uint ea = EA_AY_AI_8(); - uint lower_bound = m68ki_read_8(ea); - uint upper_bound = m68ki_read_8(ea + 1); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_8_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xff; - uint ea = EA_AY_DI_8(); - uint lower_bound = m68ki_read_8(ea); - uint upper_bound = m68ki_read_8(ea + 1); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_8_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xff; - uint ea = EA_AY_IX_8(); - uint lower_bound = m68ki_read_8(ea); - uint upper_bound = m68ki_read_8(ea + 1); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_8_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xff; - uint ea = EA_AW_8(); - uint lower_bound = m68ki_read_8(ea); - uint upper_bound = m68ki_read_8(ea + 1); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_8_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xff; - uint ea = EA_AL_8(); - uint lower_bound = m68ki_read_8(ea); - uint upper_bound = m68ki_read_8(ea + 1); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_8(compare) - MAKE_INT_8(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_16_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; - uint ea = EA_PCDI_16(); - uint lower_bound = m68ki_read_pcrel_16(ea); - uint upper_bound = m68ki_read_pcrel_16(ea + 2); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); - else - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_16_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; - uint ea = EA_PCIX_16(); - uint lower_bound = m68ki_read_pcrel_16(ea); - uint upper_bound = m68ki_read_pcrel_16(ea + 2); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); - else - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); - else - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_16_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; - uint ea = EA_AY_AI_16(); - uint lower_bound = m68ki_read_16(ea); - uint upper_bound = m68ki_read_16(ea + 2); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); - else - FLAG_C = compare - lower_bound; - - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); - else - FLAG_C = upper_bound - compare; - - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_16_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; - uint ea = EA_AY_DI_16(); - uint lower_bound = m68ki_read_16(ea); - uint upper_bound = m68ki_read_16(ea + 2); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); - else - FLAG_C = compare - lower_bound; - - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); - else - FLAG_C = upper_bound - compare; - - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_16_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; - uint ea = EA_AY_IX_16(); - uint lower_bound = m68ki_read_16(ea); - uint upper_bound = m68ki_read_16(ea + 2); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); - else - FLAG_C = compare - lower_bound; - - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); - else - FLAG_C = upper_bound - compare; - - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_16_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; - uint ea = EA_AW_16(); - uint lower_bound = m68ki_read_16(ea); - uint upper_bound = m68ki_read_16(ea + 2); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); - else - FLAG_C = compare - lower_bound; - - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); - else - FLAG_C = upper_bound - compare; - - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_16_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]&0xffff; - uint ea = EA_AL_16(); - uint lower_bound = m68ki_read_16(ea); - uint upper_bound = m68ki_read_16(ea + 2); - - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(compare) - MAKE_INT_16(lower_bound); - else - FLAG_C = compare - lower_bound; - - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - if(!BIT_F(word2)) - FLAG_C = MAKE_INT_16(upper_bound) - MAKE_INT_16(compare); - else - FLAG_C = upper_bound - compare; - - FLAG_C = CFLAG_16(FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_32_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]; - uint ea = EA_PCDI_32(); - uint lower_bound = m68ki_read_pcrel_32(ea); - uint upper_bound = m68ki_read_pcrel_32(ea + 4); - - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_32_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]; - uint ea = EA_PCIX_32(); - uint lower_bound = m68ki_read_pcrel_32(ea); - uint upper_bound = m68ki_read_pcrel_32(ea + 4); - - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_32_ai(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]; - uint ea = EA_AY_AI_32(); - uint lower_bound = m68ki_read_32(ea); - uint upper_bound = m68ki_read_32(ea + 4); - - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_32_di(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]; - uint ea = EA_AY_DI_32(); - uint lower_bound = m68ki_read_32(ea); - uint upper_bound = m68ki_read_32(ea + 4); - - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_32_ix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]; - uint ea = EA_AY_IX_32(); - uint lower_bound = m68ki_read_32(ea); - uint upper_bound = m68ki_read_32(ea + 4); - - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_32_aw(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]; - uint ea = EA_AW_32(); - uint lower_bound = m68ki_read_32(ea); - uint upper_bound = m68ki_read_32(ea + 4); - - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_chk2cmp2_32_al(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint compare = REG_DA[(word2 >> 12) & 15]; - uint ea = EA_AL_32(); - uint lower_bound = m68ki_read_32(ea); - uint upper_bound = m68ki_read_32(ea + 4); - - FLAG_C = compare - lower_bound; - FLAG_Z = !((upper_bound==compare) | (lower_bound==compare)); - FLAG_C = CFLAG_SUB_32(lower_bound, compare, FLAG_C); - if(COND_CS()) - { - if(BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - - FLAG_C = upper_bound - compare; - FLAG_C = CFLAG_SUB_32(compare, upper_bound, FLAG_C); - if(COND_CS() && BIT_B(word2)) - m68ki_exception_trap(EXCEPTION_CHK); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_clr_8_d(void) -{ - DY &= 0xffffff00; - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_8_al(void) -{ - m68ki_write_8(EA_AL_8(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_16_d(void) -{ - DY &= 0xffff0000; - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_16_ai(void) -{ - m68ki_write_16(EA_AY_AI_16(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_16_pi(void) -{ - m68ki_write_16(EA_AY_PI_16(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_16_pd(void) -{ - m68ki_write_16(EA_AY_PD_16(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_16_di(void) -{ - m68ki_write_16(EA_AY_DI_16(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_16_ix(void) -{ - m68ki_write_16(EA_AY_IX_16(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_16_aw(void) -{ - m68ki_write_16(EA_AW_16(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_16_al(void) -{ - m68ki_write_16(EA_AL_16(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_32_d(void) -{ - DY = 0; - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_32_ai(void) -{ - m68ki_write_32(EA_AY_AI_32(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_32_pi(void) -{ - m68ki_write_32(EA_AY_PI_32(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_32_pd(void) -{ - m68ki_write_32(EA_AY_PD_32(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_32_di(void) -{ - m68ki_write_32(EA_AY_DI_32(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_32_ix(void) -{ - m68ki_write_32(EA_AY_IX_32(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_32_aw(void) -{ - m68ki_write_32(EA_AW_32(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_clr_32_al(void) -{ - m68ki_write_32(EA_AL_32(), 0); - - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; -} - - -static void m68k_op_cmp_8_d(void) -{ - uint src = MASK_OUT_ABOVE_8(DY); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_ai(void) -{ - uint src = OPER_AY_AI_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_pi(void) -{ - uint src = OPER_AY_PI_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_pi7(void) -{ - uint src = OPER_A7_PI_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_pd(void) -{ - uint src = OPER_AY_PD_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_pd7(void) -{ - uint src = OPER_A7_PD_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_di(void) -{ - uint src = OPER_AY_DI_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_ix(void) -{ - uint src = OPER_AY_IX_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_aw(void) -{ - uint src = OPER_AW_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_al(void) -{ - uint src = OPER_AL_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_pcdi(void) -{ - uint src = OPER_PCDI_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_pcix(void) -{ - uint src = OPER_PCIX_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_8_i(void) -{ - uint src = OPER_I_8(); - uint dst = MASK_OUT_ABOVE_8(DX); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmp_16_d(void) -{ - uint src = MASK_OUT_ABOVE_16(DY); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_a(void) -{ - uint src = MASK_OUT_ABOVE_16(AY); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_ai(void) -{ - uint src = OPER_AY_AI_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_pi(void) -{ - uint src = OPER_AY_PI_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_pd(void) -{ - uint src = OPER_AY_PD_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_di(void) -{ - uint src = OPER_AY_DI_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_ix(void) -{ - uint src = OPER_AY_IX_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_aw(void) -{ - uint src = OPER_AW_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_al(void) -{ - uint src = OPER_AL_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_pcdi(void) -{ - uint src = OPER_PCDI_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_pcix(void) -{ - uint src = OPER_PCIX_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_16_i(void) -{ - uint src = OPER_I_16(); - uint dst = MASK_OUT_ABOVE_16(DX); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmp_32_d(void) -{ - uint src = DY; - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_a(void) -{ - uint src = AY; - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_ai(void) -{ - uint src = OPER_AY_AI_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_pi(void) -{ - uint src = OPER_AY_PI_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_pd(void) -{ - uint src = OPER_AY_PD_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_di(void) -{ - uint src = OPER_AY_DI_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_ix(void) -{ - uint src = OPER_AY_IX_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_aw(void) -{ - uint src = OPER_AW_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_al(void) -{ - uint src = OPER_AL_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_pcdi(void) -{ - uint src = OPER_PCDI_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_pcix(void) -{ - uint src = OPER_PCIX_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmp_32_i(void) -{ - uint src = OPER_I_32(); - uint dst = DX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_d(void) -{ - uint src = MAKE_INT_16(DY); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_a(void) -{ - uint src = MAKE_INT_16(AY); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_ai(void) -{ - uint src = MAKE_INT_16(OPER_AY_AI_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_pi(void) -{ - uint src = MAKE_INT_16(OPER_AY_PI_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_pd(void) -{ - uint src = MAKE_INT_16(OPER_AY_PD_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_di(void) -{ - uint src = MAKE_INT_16(OPER_AY_DI_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_ix(void) -{ - uint src = MAKE_INT_16(OPER_AY_IX_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_aw(void) -{ - uint src = MAKE_INT_16(OPER_AW_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_al(void) -{ - uint src = MAKE_INT_16(OPER_AL_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_pcdi(void) -{ - uint src = MAKE_INT_16(OPER_PCDI_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_pcix(void) -{ - uint src = MAKE_INT_16(OPER_PCIX_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_16_i(void) -{ - uint src = MAKE_INT_16(OPER_I_16()); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_d(void) -{ - uint src = DY; - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_a(void) -{ - uint src = AY; - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_ai(void) -{ - uint src = OPER_AY_AI_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_pi(void) -{ - uint src = OPER_AY_PI_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_pd(void) -{ - uint src = OPER_AY_PD_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_di(void) -{ - uint src = OPER_AY_DI_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_ix(void) -{ - uint src = OPER_AY_IX_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_aw(void) -{ - uint src = OPER_AW_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_al(void) -{ - uint src = OPER_AL_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_pcdi(void) -{ - uint src = OPER_PCDI_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_pcix(void) -{ - uint src = OPER_PCIX_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpa_32_i(void) -{ - uint src = OPER_I_32(); - uint dst = AX; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpi_8_d(void) -{ - uint src = OPER_I_8(); - uint dst = MASK_OUT_ABOVE_8(DY); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_ai(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_AY_AI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_pi(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_AY_PI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_pi7(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_A7_PI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_pd(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_AY_PD_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_pd7(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_A7_PD_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_di(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_AY_DI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_ix(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_AY_IX_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_aw(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_AW_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpi_8_al(void) -{ - uint src = OPER_I_8(); - uint dst = OPER_AL_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_cmpi_8_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint src = OPER_I_8(); - uint dst = OPER_PCDI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cmpi_8_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint src = OPER_I_8(); - uint dst = OPER_PCIX_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_cmpi_16_d(void) -{ - uint src = OPER_I_16(); - uint dst = MASK_OUT_ABOVE_16(DY); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmpi_16_ai(void) -{ - uint src = OPER_I_16(); - uint dst = OPER_AY_AI_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmpi_16_pi(void) -{ - uint src = OPER_I_16(); - uint dst = OPER_AY_PI_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmpi_16_pd(void) -{ - uint src = OPER_I_16(); - uint dst = OPER_AY_PD_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmpi_16_di(void) -{ - uint src = OPER_I_16(); - uint dst = OPER_AY_DI_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmpi_16_ix(void) -{ - uint src = OPER_I_16(); - uint dst = OPER_AY_IX_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmpi_16_aw(void) -{ - uint src = OPER_I_16(); - uint dst = OPER_AW_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmpi_16_al(void) -{ - uint src = OPER_I_16(); - uint dst = OPER_AL_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_cmpi_16_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint src = OPER_I_16(); - uint dst = OPER_PCDI_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cmpi_16_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint src = OPER_I_16(); - uint dst = OPER_PCIX_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_cmpi_32_d(void) -{ - uint src = OPER_I_32(); - uint dst = DY; - uint res = dst - src; - - m68ki_cmpild_callback(src, REG_IR & 7); /* auto-disable (see m68kcpu.h) */ - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpi_32_ai(void) -{ - uint src = OPER_I_32(); - uint dst = OPER_AY_AI_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpi_32_pi(void) -{ - uint src = OPER_I_32(); - uint dst = OPER_AY_PI_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpi_32_pd(void) -{ - uint src = OPER_I_32(); - uint dst = OPER_AY_PD_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpi_32_di(void) -{ - uint src = OPER_I_32(); - uint dst = OPER_AY_DI_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpi_32_ix(void) -{ - uint src = OPER_I_32(); - uint dst = OPER_AY_IX_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpi_32_aw(void) -{ - uint src = OPER_I_32(); - uint dst = OPER_AW_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -static void m68k_op_cmpi_32_al(void) -{ - uint src = OPER_I_32(); - uint dst = OPER_AL_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_cmpi_32_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint src = OPER_I_32(); - uint dst = OPER_PCDI_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_cmpi_32_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint src = OPER_I_32(); - uint dst = OPER_PCIX_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_cmpm_8_ax7(void) -{ - uint src = OPER_AY_PI_8(); - uint dst = OPER_A7_PI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpm_8_ay7(void) -{ - uint src = OPER_A7_PI_8(); - uint dst = OPER_AX_PI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpm_8_axy7(void) -{ - uint src = OPER_A7_PI_8(); - uint dst = OPER_A7_PI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpm_8(void) -{ - uint src = OPER_AY_PI_8(); - uint dst = OPER_AX_PI_8(); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_C = CFLAG_8(res); -} - - -static void m68k_op_cmpm_16(void) -{ - uint src = OPER_AY_PI_16(); - uint dst = OPER_AX_PI_16(); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_C = CFLAG_16(res); -} - - -static void m68k_op_cmpm_32(void) -{ - uint src = OPER_AY_PI_32(); - uint dst = OPER_AX_PI_32(); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_C = CFLAG_SUB_32(src, dst, res); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_cpbcc_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_1111(); -} - - -static void m68k_op_cpdbcc_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_1111(); -} - - -static void m68k_op_cpgen_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_1111(); -} - - -static void m68k_op_cpscc_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_1111(); -} - - -static void m68k_op_cptrapcc_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_1111(); -} -#endif - - -static void m68k_op_dbt_16(void) -{ - REG_PC += 2; -} - - -static void m68k_op_dbf_16(void) -{ - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); -} - - -static void m68k_op_dbhi_16(void) -{ - if(COND_NOT_HI()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbls_16(void) -{ - if(COND_NOT_LS()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbcc_16(void) -{ - if(COND_NOT_CC()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbcs_16(void) -{ - if(COND_NOT_CS()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbne_16(void) -{ - if(COND_NOT_NE()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbeq_16(void) -{ - if(COND_NOT_EQ()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbvc_16(void) -{ - if(COND_NOT_VC()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbvs_16(void) -{ - if(COND_NOT_VS()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbpl_16(void) -{ - if(COND_NOT_PL()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbmi_16(void) -{ - if(COND_NOT_MI()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbge_16(void) -{ - if(COND_NOT_GE()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dblt_16(void) -{ - if(COND_NOT_LT()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dbgt_16(void) -{ - if(COND_NOT_GT()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_dble_16(void) -{ - if(COND_NOT_LE()) - { - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(*r_dst - 1); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - if(res != 0xffff) - { - uint offset = OPER_I_16(); - REG_PC -= 2; - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_branch_16(offset); - USE_CYCLES(CYC_DBCC_F_NOEXP); - return; - } - REG_PC += 2; - USE_CYCLES(CYC_DBCC_F_EXP); - return; - } - REG_PC += 2; -} - - -static void m68k_op_divs_16_d(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(DY); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_ai(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_AY_AI_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_pi(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_AY_PI_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_pd(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_AY_PD_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_di(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_AY_DI_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_ix(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_AY_IX_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_aw(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_AW_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_al(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_AL_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_pcdi(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_PCDI_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_pcix(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_PCIX_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divs_16_i(void) -{ - uint* r_dst = &DX; - sint src = MAKE_INT_16(OPER_I_16()); - sint quotient; - sint remainder; - - if(src != 0) - { - int cyc = getDivs68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - if((uint32)*r_dst == 0x80000000 && src == -1) - { - FLAG_Z = 0; - FLAG_N = NFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = 0; - return; - } - - quotient = MAKE_INT_32(*r_dst) / src; - remainder = MAKE_INT_32(*r_dst) % src; - - if(quotient == MAKE_INT_16(quotient)) - { - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_d(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_16(DY); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_ai(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_AI_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_pi(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PI_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_pd(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PD_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_di(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_DI_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_ix(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_IX_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_aw(void) -{ - uint* r_dst = &DX; - uint src = OPER_AW_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_al(void) -{ - uint* r_dst = &DX; - uint src = OPER_AL_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_pcdi(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCDI_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_pcix(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCIX_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -static void m68k_op_divu_16_i(void) -{ - uint* r_dst = &DX; - uint src = OPER_I_16(); - - if(src != 0) - { - uint quotient = *r_dst / src; - uint remainder = *r_dst % src; - - if(quotient < 0x10000) - { - int cyc = getDivu68kCycles(*r_dst,src); - USE_CYCLES(cyc); - - FLAG_Z = quotient; - FLAG_N = NFLAG_16(quotient); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); - return; - } - USE_CYCLES(70); - FLAG_V = VFLAG_SET; - FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ - FLAG_C = CFLAG_CLEAR; - return; - } - FLAG_C = CFLAG_CLEAR; - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_divl_32_d(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = DY; - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = DY; - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_ai(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_AY_AI_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_AY_AI_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_pi(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_AY_PI_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_AY_PI_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_pd(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_AY_PD_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_AY_PD_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_di(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_AY_DI_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_AY_DI_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_ix(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_AY_IX_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_AY_IX_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_aw(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_AW_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_AW_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_al(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_AL_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_AL_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_pcdi(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_PCDI_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_PCDI_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_pcix(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_PCIX_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_PCIX_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_divl_32_i(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 divisor = OPER_I_32(); - uint64 dividend = 0; - uint64 quotient = 0; - uint64 remainder = 0; - - if(divisor != 0) - { - if(BIT_A(word2)) /* 64 bit */ - { - dividend = REG_D[word2 & 7]; - dividend <<= 32; - dividend |= REG_D[(word2 >> 12) & 7]; - - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)dividend / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)dividend % (sint64)((sint32)divisor)); - if((sint64)quotient != (sint64)((sint32)quotient)) - { - FLAG_V = VFLAG_SET; - return; - } - } - else /* unsigned */ - { - quotient = dividend / divisor; - if(quotient > 0xffffffff) - { - FLAG_V = VFLAG_SET; - return; - } - remainder = dividend % divisor; - } - } - else /* 32 bit */ - { - dividend = REG_D[(word2 >> 12) & 7]; - if(BIT_B(word2)) /* signed */ - { - quotient = (uint64)((sint64)((sint32)dividend) / (sint64)((sint32)divisor)); - remainder = (uint64)((sint64)((sint32)dividend) % (sint64)((sint32)divisor)); - } - else /* unsigned */ - { - quotient = dividend / divisor; - remainder = dividend % divisor; - } - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint divisor = OPER_I_32(); - uint dividend_hi = REG_D[word2 & 7]; - uint dividend_lo = REG_D[(word2 >> 12) & 7]; - uint quotient = 0; - uint remainder = 0; - uint dividend_neg = 0; - uint divisor_neg = 0; - sint i; - uint overflow; - - if(divisor != 0) - { - /* quad / long : long quotient, long remainder */ - if(BIT_A(word2)) - { - if(BIT_B(word2)) /* signed */ - { - /* special case in signed divide */ - if(dividend_hi == 0 && dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - REG_D[word2 & 7] = 0; - REG_D[(word2 >> 12) & 7] = 0x80000000; - - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - if(GET_MSB_32(dividend_hi)) - { - dividend_neg = 1; - dividend_hi = (uint)MASK_OUT_ABOVE_32((-(sint)dividend_hi) - (dividend_lo != 0)); - dividend_lo = (uint)MASK_OUT_ABOVE_32(-(sint)dividend_lo); - } - if(GET_MSB_32(divisor)) - { - divisor_neg = 1; - divisor = (uint)MASK_OUT_ABOVE_32(-(sint)divisor); - - } - } - - /* if the upper long is greater than the divisor, we're overflowing. */ - if(dividend_hi >= divisor) - { - FLAG_V = VFLAG_SET; - return; - } - - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - remainder = (remainder << 1) + ((dividend_hi >> i) & 1); - if(remainder >= divisor) - { - remainder -= divisor; - quotient++; - } - } - for(i = 31; i >= 0; i--) - { - quotient <<= 1; - overflow = GET_MSB_32(remainder); - remainder = (remainder << 1) + ((dividend_lo >> i) & 1); - if(remainder >= divisor || overflow) - { - remainder -= divisor; - quotient++; - } - } - - if(BIT_B(word2)) /* signed */ - { - if(quotient > 0x7fffffff) - { - FLAG_V = VFLAG_SET; - return; - } - if(dividend_neg) - { - remainder = (uint)MASK_OUT_ABOVE_32(-(sint)remainder); - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - if(divisor_neg) - quotient = (uint)MASK_OUT_ABOVE_32(-(sint)quotient); - } - - REG_D[word2 & 7] = remainder; - REG_D[(word2 >> 12) & 7] = quotient; - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - - /* long / long: long quotient, maybe long remainder */ - if(BIT_B(word2)) /* signed */ - { - /* Special case in divide */ - if(dividend_lo == 0x80000000 && divisor == 0xffffffff) - { - FLAG_N = NFLAG_SET; - FLAG_Z = ZFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - REG_D[(word2 >> 12) & 7] = 0x80000000; - REG_D[word2 & 7] = 0; - return; - } - REG_D[word2 & 7] = MAKE_INT_32(dividend_lo) % MAKE_INT_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MAKE_INT_32(dividend_lo) / MAKE_INT_32(divisor); - } - else - { - REG_D[word2 & 7] = MASK_OUT_ABOVE_32(dividend_lo) % MASK_OUT_ABOVE_32(divisor); - quotient = REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(dividend_lo) / MASK_OUT_ABOVE_32(divisor); - } - - FLAG_N = NFLAG_32(quotient); - FLAG_Z = quotient; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); - return; - } - m68ki_exception_illegal(); - -#endif -} -#endif - - -static void m68k_op_eor_8_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY ^= MASK_OUT_ABOVE_8(DX)); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_di(void) -{ - uint ea = EA_AY_DI_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_aw(void) -{ - uint ea = EA_AW_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_8_al(void) -{ - uint ea = EA_AL_8(); - uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_16_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY ^= MASK_OUT_ABOVE_16(DX)); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_16_aw(void) -{ - uint ea = EA_AW_16(); - uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_16_al(void) -{ - uint ea = EA_AL_16(); - uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_32_d(void) -{ - uint res = DY ^= DX; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_32_ai(void) -{ - uint ea = EA_AY_AI_32(); - uint res = DX ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_32_pi(void) -{ - uint ea = EA_AY_PI_32(); - uint res = DX ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_32_pd(void) -{ - uint ea = EA_AY_PD_32(); - uint res = DX ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_32_di(void) -{ - uint ea = EA_AY_DI_32(); - uint res = DX ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_32_ix(void) -{ - uint ea = EA_AY_IX_32(); - uint res = DX ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_32_aw(void) -{ - uint ea = EA_AW_32(); - uint res = DX ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eor_32_al(void) -{ - uint ea = EA_AL_32(); - uint res = DX ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY ^= OPER_I_8()); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_ai(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_AI_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_pi(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PI_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_pi7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PI_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_pd(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PD_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_pd7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PD_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_di(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_DI_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_ix(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_IX_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_aw(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AW_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_8_al(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AL_8(); - uint res = src ^ m68ki_read_8(ea); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY ^= OPER_I_16()); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_ai(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_AI_16(); - uint res = src ^ m68ki_read_16(ea); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_pi(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PI_16(); - uint res = src ^ m68ki_read_16(ea); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_pd(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PD_16(); - uint res = src ^ m68ki_read_16(ea); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_di(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_DI_16(); - uint res = src ^ m68ki_read_16(ea); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_ix(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_IX_16(); - uint res = src ^ m68ki_read_16(ea); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_aw(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AW_16(); - uint res = src ^ m68ki_read_16(ea); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_al(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AL_16(); - uint res = src ^ m68ki_read_16(ea); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_32_d(void) -{ - uint res = DY ^= OPER_I_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_32_ai(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_AI_32(); - uint res = src ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_32_pi(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PI_32(); - uint res = src ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_32_pd(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PD_32(); - uint res = src ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_32_di(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_DI_32(); - uint res = src ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_32_ix(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_IX_32(); - uint res = src ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_32_aw(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AW_32(); - uint res = src ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_32_al(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AL_32(); - uint res = src ^ m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_eori_16_toc(void) -{ - m68ki_set_ccr(m68ki_get_ccr() ^ OPER_I_16()); -} - - -static void m68k_op_eori_16_tos(void) -{ - if(FLAG_S) - { - uint src = OPER_I_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(m68ki_get_sr() ^ src); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_exg_32_dd(void) -{ - uint* reg_a = &DX; - uint* reg_b = &DY; - uint tmp = *reg_a; - *reg_a = *reg_b; - *reg_b = tmp; -} - - -static void m68k_op_exg_32_aa(void) -{ - uint* reg_a = &AX; - uint* reg_b = &AY; - uint tmp = *reg_a; - *reg_a = *reg_b; - *reg_b = tmp; -} - - -static void m68k_op_exg_32_da(void) -{ - uint* reg_a = &DX; - uint* reg_b = &AY; - uint tmp = *reg_a; - *reg_a = *reg_b; - *reg_b = tmp; -} - - -static void m68k_op_ext_16(void) -{ - uint* r_dst = &DY; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | MASK_OUT_ABOVE_8(*r_dst) | (GET_MSB_8(*r_dst) ? 0xff00 : 0); - - FLAG_N = NFLAG_16(*r_dst); - FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_ext_32(void) -{ - uint* r_dst = &DY; - - *r_dst = MASK_OUT_ABOVE_16(*r_dst) | (GET_MSB_16(*r_dst) ? 0xffff0000 : 0); - - FLAG_N = NFLAG_32(*r_dst); - FLAG_Z = *r_dst; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_extb_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint* r_dst = &DY; - - *r_dst = MASK_OUT_ABOVE_8(*r_dst) | (GET_MSB_8(*r_dst) ? 0xffffff00 : 0); - - FLAG_N = NFLAG_32(*r_dst); - FLAG_Z = *r_dst; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_illegal(void) -{ - m68ki_exception_illegal(); -} - - -static void m68k_op_jmp_32_ai(void) -{ - m68ki_jump(EA_AY_AI_32()); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_jmp_32_di(void) -{ - m68ki_jump(EA_AY_DI_32()); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_jmp_32_ix(void) -{ - m68ki_jump(EA_AY_IX_32()); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_jmp_32_aw(void) -{ - m68ki_jump(EA_AW_32()); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_jmp_32_al(void) -{ - m68ki_jump(EA_AL_32()); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_jmp_32_pcdi(void) -{ - m68ki_jump(EA_PCDI_32()); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_jmp_32_pcix(void) -{ - m68ki_jump(EA_PCIX_32()); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_check_infinite_loop(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_jsr_32_ai(void) -{ - uint ea = EA_AY_AI_32(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_jump(ea); -} - - -static void m68k_op_jsr_32_di(void) -{ - uint ea = EA_AY_DI_32(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_jump(ea); -} - - -static void m68k_op_jsr_32_ix(void) -{ - uint ea = EA_AY_IX_32(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_jump(ea); -} - - -static void m68k_op_jsr_32_aw(void) -{ - uint ea = EA_AW_32(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_jump(ea); -} - - -static void m68k_op_jsr_32_al(void) -{ - uint ea = EA_AL_32(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_jump(ea); -} - - -static void m68k_op_jsr_32_pcdi(void) -{ - uint ea = EA_PCDI_32(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_jump(ea); -} - - -static void m68k_op_jsr_32_pcix(void) -{ - uint ea = EA_PCIX_32(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_push_32(REG_PC); - m68ki_jump(ea); -} - - -static void m68k_op_lea_32_ai(void) -{ - AX = EA_AY_AI_32(); -} - - -static void m68k_op_lea_32_di(void) -{ - AX = EA_AY_DI_32(); -} - - -static void m68k_op_lea_32_ix(void) -{ - AX = EA_AY_IX_32(); -} - - -static void m68k_op_lea_32_aw(void) -{ - AX = EA_AW_32(); -} - - -static void m68k_op_lea_32_al(void) -{ - AX = EA_AL_32(); -} - - -static void m68k_op_lea_32_pcdi(void) -{ - AX = EA_PCDI_32(); -} - - -static void m68k_op_lea_32_pcix(void) -{ - AX = EA_PCIX_32(); -} - - -static void m68k_op_link_16_a7(void) -{ - REG_A[7] -= 4; - m68ki_write_32(REG_A[7], REG_A[7]); - REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16())); -} - - -static void m68k_op_link_16(void) -{ - uint* r_dst = &AY; - - m68ki_push_32(*r_dst); - *r_dst = REG_A[7]; - REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16())); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_link_32_a7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - REG_A[7] -= 4; - m68ki_write_32(REG_A[7], REG_A[7]); - REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + OPER_I_32()); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_link_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint* r_dst = &AY; - - m68ki_push_32(*r_dst); - *r_dst = REG_A[7]; - REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + OPER_I_32()); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_lsr_8_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = src >> shift; - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_X = FLAG_C = src << (9-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = src >> shift; - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_X = FLAG_C = src << (9-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_32_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = *r_dst; - uint res = src >> shift; - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = res; - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_X = FLAG_C = src << (9-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_8_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = src >> shift; - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift <= 8) - { - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - FLAG_X = FLAG_C = src << (9-shift); - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst &= 0xffffff00; - FLAG_X = XFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_8(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = src >> shift; - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift <= 16) - { - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - FLAG_C = FLAG_X = (src >> (shift - 1))<<8; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst &= 0xffff0000; - FLAG_X = XFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_16(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_32_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = *r_dst; - uint res = src >> shift; - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift < 32) - { - *r_dst = res; - FLAG_C = FLAG_X = (src >> (shift - 1))<<8; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst = 0; - FLAG_X = FLAG_C = (shift == 32 ? GET_MSB_32(src)>>23 : 0); - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_32(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_C = FLAG_X = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_C = FLAG_X = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_C = FLAG_X = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_C = FLAG_X = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_C = FLAG_X = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_C = FLAG_X = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsr_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = src >> 1; - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_CLEAR; - FLAG_Z = res; - FLAG_C = FLAG_X = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_8_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = MASK_OUT_ABOVE_8(src << shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src << shift; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = MASK_OUT_ABOVE_16(src << shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> (8-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_32_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = *r_dst; - uint res = MASK_OUT_ABOVE_32(src << shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> (24-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_8_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = MASK_OUT_ABOVE_8(src << shift); - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift <= 8) - { - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - FLAG_X = FLAG_C = src << shift; - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst &= 0xffffff00; - FLAG_X = XFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_8(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = MASK_OUT_ABOVE_16(src << shift); - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift <= 16) - { - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - FLAG_X = FLAG_C = (src << shift) >> 8; - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst &= 0xffff0000; - FLAG_X = XFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_16(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_32_r(void) -{ - uint* r_dst = &DY; - uint shift = DX & 0x3f; - uint src = *r_dst; - uint res = MASK_OUT_ABOVE_32(src << shift); - - if(shift != 0) - { - USE_CYCLES(shift * CYC_SHIFT); - - if(shift < 32) - { - *r_dst = res; - FLAG_X = FLAG_C = (src >> (32 - shift)) << 8; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - *r_dst = 0; - FLAG_X = FLAG_C = ((shift == 32 ? src & 1 : 0))<<8; - FLAG_N = NFLAG_CLEAR; - FLAG_Z = ZFLAG_SET; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_32(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_lsl_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(src << 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_X = FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_di(void) -{ - uint res = OPER_AY_DI_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_aw(void) -{ - uint res = OPER_AW_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_al(void) -{ - uint res = OPER_AL_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_d_i(void) -{ - uint res = OPER_I_8(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ai_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_AX_AI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi7_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_A7_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pi_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_AX_PI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd7_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_A7_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_pd_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_AX_PD_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_di_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_AX_DI_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_ix_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_AX_IX_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_aw_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_AW_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_ai(void) -{ - uint res = OPER_AY_AI_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_pi(void) -{ - uint res = OPER_AY_PI_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_pi7(void) -{ - uint res = OPER_A7_PI_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_pd(void) -{ - uint res = OPER_AY_PD_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_pd7(void) -{ - uint res = OPER_A7_PD_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_di(void) -{ - uint res = OPER_AY_DI_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_ix(void) -{ - uint res = OPER_AY_IX_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_aw(void) -{ - uint res = OPER_AW_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_al(void) -{ - uint res = OPER_AL_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_pcdi(void) -{ - uint res = OPER_PCDI_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_pcix(void) -{ - uint res = OPER_PCIX_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_8_al_i(void) -{ - uint res = OPER_I_8(); - uint ea = EA_AL_8(); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_a(void) -{ - uint res = MASK_OUT_ABOVE_16(AY); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_ai(void) -{ - uint res = OPER_AY_AI_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_pi(void) -{ - uint res = OPER_AY_PI_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_pd(void) -{ - uint res = OPER_AY_PD_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_di(void) -{ - uint res = OPER_AY_DI_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_ix(void) -{ - uint res = OPER_AY_IX_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_aw(void) -{ - uint res = OPER_AW_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_al(void) -{ - uint res = OPER_AL_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_pcdi(void) -{ - uint res = OPER_PCDI_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_pcix(void) -{ - uint res = OPER_PCIX_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_d_i(void) -{ - uint res = OPER_I_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_a(void) -{ - uint res = MASK_OUT_ABOVE_16(AY); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_ai(void) -{ - uint res = OPER_AY_AI_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_pi(void) -{ - uint res = OPER_AY_PI_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_pd(void) -{ - uint res = OPER_AY_PD_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_di(void) -{ - uint res = OPER_AY_DI_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_ix(void) -{ - uint res = OPER_AY_IX_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_aw(void) -{ - uint res = OPER_AW_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_al(void) -{ - uint res = OPER_AL_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_pcdi(void) -{ - uint res = OPER_PCDI_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_pcix(void) -{ - uint res = OPER_PCIX_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ai_i(void) -{ - uint res = OPER_I_16(); - uint ea = EA_AX_AI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_a(void) -{ - uint res = MASK_OUT_ABOVE_16(AY); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_ai(void) -{ - uint res = OPER_AY_AI_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_pi(void) -{ - uint res = OPER_AY_PI_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_pd(void) -{ - uint res = OPER_AY_PD_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_di(void) -{ - uint res = OPER_AY_DI_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_ix(void) -{ - uint res = OPER_AY_IX_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_aw(void) -{ - uint res = OPER_AW_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_al(void) -{ - uint res = OPER_AL_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_pcdi(void) -{ - uint res = OPER_PCDI_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_pcix(void) -{ - uint res = OPER_PCIX_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pi_i(void) -{ - uint res = OPER_I_16(); - uint ea = EA_AX_PI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_a(void) -{ - uint res = MASK_OUT_ABOVE_16(AY); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_ai(void) -{ - uint res = OPER_AY_AI_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_pi(void) -{ - uint res = OPER_AY_PI_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_pd(void) -{ - uint res = OPER_AY_PD_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_di(void) -{ - uint res = OPER_AY_DI_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_ix(void) -{ - uint res = OPER_AY_IX_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_aw(void) -{ - uint res = OPER_AW_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_al(void) -{ - uint res = OPER_AL_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_pcdi(void) -{ - uint res = OPER_PCDI_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_pcix(void) -{ - uint res = OPER_PCIX_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_pd_i(void) -{ - uint res = OPER_I_16(); - uint ea = EA_AX_PD_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_a(void) -{ - uint res = MASK_OUT_ABOVE_16(AY); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_ai(void) -{ - uint res = OPER_AY_AI_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_pi(void) -{ - uint res = OPER_AY_PI_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_pd(void) -{ - uint res = OPER_AY_PD_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_di(void) -{ - uint res = OPER_AY_DI_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_ix(void) -{ - uint res = OPER_AY_IX_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_aw(void) -{ - uint res = OPER_AW_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_al(void) -{ - uint res = OPER_AL_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_pcdi(void) -{ - uint res = OPER_PCDI_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_pcix(void) -{ - uint res = OPER_PCIX_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_di_i(void) -{ - uint res = OPER_I_16(); - uint ea = EA_AX_DI_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_a(void) -{ - uint res = MASK_OUT_ABOVE_16(AY); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_ai(void) -{ - uint res = OPER_AY_AI_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_pi(void) -{ - uint res = OPER_AY_PI_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_pd(void) -{ - uint res = OPER_AY_PD_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_di(void) -{ - uint res = OPER_AY_DI_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_ix(void) -{ - uint res = OPER_AY_IX_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_aw(void) -{ - uint res = OPER_AW_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_al(void) -{ - uint res = OPER_AL_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_pcdi(void) -{ - uint res = OPER_PCDI_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_pcix(void) -{ - uint res = OPER_PCIX_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_ix_i(void) -{ - uint res = OPER_I_16(); - uint ea = EA_AX_IX_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_a(void) -{ - uint res = MASK_OUT_ABOVE_16(AY); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_ai(void) -{ - uint res = OPER_AY_AI_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_pi(void) -{ - uint res = OPER_AY_PI_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_pd(void) -{ - uint res = OPER_AY_PD_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_di(void) -{ - uint res = OPER_AY_DI_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_ix(void) -{ - uint res = OPER_AY_IX_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_aw(void) -{ - uint res = OPER_AW_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_al(void) -{ - uint res = OPER_AL_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_pcdi(void) -{ - uint res = OPER_PCDI_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_pcix(void) -{ - uint res = OPER_PCIX_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_aw_i(void) -{ - uint res = OPER_I_16(); - uint ea = EA_AW_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_a(void) -{ - uint res = MASK_OUT_ABOVE_16(AY); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_ai(void) -{ - uint res = OPER_AY_AI_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_pi(void) -{ - uint res = OPER_AY_PI_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_pd(void) -{ - uint res = OPER_AY_PD_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_di(void) -{ - uint res = OPER_AY_DI_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_ix(void) -{ - uint res = OPER_AY_IX_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_aw(void) -{ - uint res = OPER_AW_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_al(void) -{ - uint res = OPER_AL_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_pcdi(void) -{ - uint res = OPER_PCDI_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_pcix(void) -{ - uint res = OPER_PCIX_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_16_al_i(void) -{ - uint res = OPER_I_16(); - uint ea = EA_AL_16(); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_d(void) -{ - uint res = DY; - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_a(void) -{ - uint res = AY; - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_ai(void) -{ - uint res = OPER_AY_AI_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_pi(void) -{ - uint res = OPER_AY_PI_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_pd(void) -{ - uint res = OPER_AY_PD_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_di(void) -{ - uint res = OPER_AY_DI_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_ix(void) -{ - uint res = OPER_AY_IX_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_aw(void) -{ - uint res = OPER_AW_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_al(void) -{ - uint res = OPER_AL_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_pcdi(void) -{ - uint res = OPER_PCDI_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_pcix(void) -{ - uint res = OPER_PCIX_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_d_i(void) -{ - uint res = OPER_I_32(); - uint* r_dst = &DX; - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_d(void) -{ - uint res = DY; - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_a(void) -{ - uint res = AY; - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_ai(void) -{ - uint res = OPER_AY_AI_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_pi(void) -{ - uint res = OPER_AY_PI_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_pd(void) -{ - uint res = OPER_AY_PD_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_di(void) -{ - uint res = OPER_AY_DI_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_ix(void) -{ - uint res = OPER_AY_IX_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_aw(void) -{ - uint res = OPER_AW_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_al(void) -{ - uint res = OPER_AL_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_pcdi(void) -{ - uint res = OPER_PCDI_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_pcix(void) -{ - uint res = OPER_PCIX_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ai_i(void) -{ - uint res = OPER_I_32(); - uint ea = EA_AX_AI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_d(void) -{ - uint res = DY; - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_a(void) -{ - uint res = AY; - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_ai(void) -{ - uint res = OPER_AY_AI_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_pi(void) -{ - uint res = OPER_AY_PI_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_pd(void) -{ - uint res = OPER_AY_PD_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_di(void) -{ - uint res = OPER_AY_DI_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_ix(void) -{ - uint res = OPER_AY_IX_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_aw(void) -{ - uint res = OPER_AW_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_al(void) -{ - uint res = OPER_AL_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_pcdi(void) -{ - uint res = OPER_PCDI_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_pcix(void) -{ - uint res = OPER_PCIX_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pi_i(void) -{ - uint res = OPER_I_32(); - uint ea = EA_AX_PI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_d(void) -{ - uint res = DY; - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_a(void) -{ - uint res = AY; - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_ai(void) -{ - uint res = OPER_AY_AI_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_pi(void) -{ - uint res = OPER_AY_PI_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_pd(void) -{ - uint res = OPER_AY_PD_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_di(void) -{ - uint res = OPER_AY_DI_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_ix(void) -{ - uint res = OPER_AY_IX_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_aw(void) -{ - uint res = OPER_AW_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_al(void) -{ - uint res = OPER_AL_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_pcdi(void) -{ - uint res = OPER_PCDI_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_pcix(void) -{ - uint res = OPER_PCIX_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_pd_i(void) -{ - uint res = OPER_I_32(); - uint ea = EA_AX_PD_32(); - - m68ki_write_16(ea+2, res & 0xFFFF ); - m68ki_write_16(ea, (res >> 16) & 0xFFFF ); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_d(void) -{ - uint res = DY; - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_a(void) -{ - uint res = AY; - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_ai(void) -{ - uint res = OPER_AY_AI_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_pi(void) -{ - uint res = OPER_AY_PI_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_pd(void) -{ - uint res = OPER_AY_PD_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_di(void) -{ - uint res = OPER_AY_DI_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_ix(void) -{ - uint res = OPER_AY_IX_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_aw(void) -{ - uint res = OPER_AW_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_al(void) -{ - uint res = OPER_AL_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_pcdi(void) -{ - uint res = OPER_PCDI_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_pcix(void) -{ - uint res = OPER_PCIX_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_di_i(void) -{ - uint res = OPER_I_32(); - uint ea = EA_AX_DI_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_d(void) -{ - uint res = DY; - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_a(void) -{ - uint res = AY; - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_ai(void) -{ - uint res = OPER_AY_AI_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_pi(void) -{ - uint res = OPER_AY_PI_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_pd(void) -{ - uint res = OPER_AY_PD_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_di(void) -{ - uint res = OPER_AY_DI_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_ix(void) -{ - uint res = OPER_AY_IX_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_aw(void) -{ - uint res = OPER_AW_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_al(void) -{ - uint res = OPER_AL_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_pcdi(void) -{ - uint res = OPER_PCDI_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_pcix(void) -{ - uint res = OPER_PCIX_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_ix_i(void) -{ - uint res = OPER_I_32(); - uint ea = EA_AX_IX_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_d(void) -{ - uint res = DY; - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_a(void) -{ - uint res = AY; - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_ai(void) -{ - uint res = OPER_AY_AI_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_pi(void) -{ - uint res = OPER_AY_PI_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_pd(void) -{ - uint res = OPER_AY_PD_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_di(void) -{ - uint res = OPER_AY_DI_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_ix(void) -{ - uint res = OPER_AY_IX_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_aw(void) -{ - uint res = OPER_AW_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_al(void) -{ - uint res = OPER_AL_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_pcdi(void) -{ - uint res = OPER_PCDI_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_pcix(void) -{ - uint res = OPER_PCIX_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_aw_i(void) -{ - uint res = OPER_I_32(); - uint ea = EA_AW_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_d(void) -{ - uint res = DY; - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_a(void) -{ - uint res = AY; - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_ai(void) -{ - uint res = OPER_AY_AI_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_pi(void) -{ - uint res = OPER_AY_PI_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_pd(void) -{ - uint res = OPER_AY_PD_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_di(void) -{ - uint res = OPER_AY_DI_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_ix(void) -{ - uint res = OPER_AY_IX_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_aw(void) -{ - uint res = OPER_AW_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_al(void) -{ - uint res = OPER_AL_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_pcdi(void) -{ - uint res = OPER_PCDI_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_pcix(void) -{ - uint res = OPER_PCIX_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move_32_al_i(void) -{ - uint res = OPER_I_32(); - uint ea = EA_AL_32(); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_movea_16_d(void) -{ - AX = MAKE_INT_16(DY); -} - - -static void m68k_op_movea_16_a(void) -{ - AX = MAKE_INT_16(AY); -} - - -static void m68k_op_movea_16_ai(void) -{ - AX = MAKE_INT_16(OPER_AY_AI_16()); -} - - -static void m68k_op_movea_16_pi(void) -{ - AX = MAKE_INT_16(OPER_AY_PI_16()); -} - - -static void m68k_op_movea_16_pd(void) -{ - AX = MAKE_INT_16(OPER_AY_PD_16()); -} - - -static void m68k_op_movea_16_di(void) -{ - AX = MAKE_INT_16(OPER_AY_DI_16()); -} - - -static void m68k_op_movea_16_ix(void) -{ - AX = MAKE_INT_16(OPER_AY_IX_16()); -} - - -static void m68k_op_movea_16_aw(void) -{ - AX = MAKE_INT_16(OPER_AW_16()); -} - - -static void m68k_op_movea_16_al(void) -{ - AX = MAKE_INT_16(OPER_AL_16()); -} - - -static void m68k_op_movea_16_pcdi(void) -{ - AX = MAKE_INT_16(OPER_PCDI_16()); -} - - -static void m68k_op_movea_16_pcix(void) -{ - AX = MAKE_INT_16(OPER_PCIX_16()); -} - - -static void m68k_op_movea_16_i(void) -{ - AX = MAKE_INT_16(OPER_I_16()); -} - - -static void m68k_op_movea_32_d(void) -{ - AX = DY; -} - - -static void m68k_op_movea_32_a(void) -{ - AX = AY; -} - - -static void m68k_op_movea_32_ai(void) -{ - AX = OPER_AY_AI_32(); -} - - -static void m68k_op_movea_32_pi(void) -{ - AX = OPER_AY_PI_32(); -} - - -static void m68k_op_movea_32_pd(void) -{ - AX = OPER_AY_PD_32(); -} - - -static void m68k_op_movea_32_di(void) -{ - AX = OPER_AY_DI_32(); -} - - -static void m68k_op_movea_32_ix(void) -{ - AX = OPER_AY_IX_32(); -} - - -static void m68k_op_movea_32_aw(void) -{ - AX = OPER_AW_32(); -} - - -static void m68k_op_movea_32_al(void) -{ - AX = OPER_AL_32(); -} - - -static void m68k_op_movea_32_pcdi(void) -{ - AX = OPER_PCDI_32(); -} - - -static void m68k_op_movea_32_pcix(void) -{ - AX = OPER_PCIX_32(); -} - - -static void m68k_op_movea_32_i(void) -{ - AX = OPER_I_32(); -} - - -#if M68K_EMULATE_010 ||M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_move_16_frc_d(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - DY = MASK_OUT_BELOW_16(DY) | m68ki_get_ccr(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_move_16_frc_ai(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - m68ki_write_16(EA_AY_AI_16(), m68ki_get_ccr()); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_move_16_frc_pi(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - m68ki_write_16(EA_AY_PI_16(), m68ki_get_ccr()); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_move_16_frc_pd(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - m68ki_write_16(EA_AY_PD_16(), m68ki_get_ccr()); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_move_16_frc_di(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - m68ki_write_16(EA_AY_DI_16(), m68ki_get_ccr()); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_move_16_frc_ix(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - m68ki_write_16(EA_AY_IX_16(), m68ki_get_ccr()); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_move_16_frc_aw(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - m68ki_write_16(EA_AW_16(), m68ki_get_ccr()); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_move_16_frc_al(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - m68ki_write_16(EA_AL_16(), m68ki_get_ccr()); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_move_16_toc_d(void) -{ - m68ki_set_ccr(DY); -} - - -static void m68k_op_move_16_toc_ai(void) -{ - m68ki_set_ccr(OPER_AY_AI_16()); -} - - -static void m68k_op_move_16_toc_pi(void) -{ - m68ki_set_ccr(OPER_AY_PI_16()); -} - - -static void m68k_op_move_16_toc_pd(void) -{ - m68ki_set_ccr(OPER_AY_PD_16()); -} - - -static void m68k_op_move_16_toc_di(void) -{ - m68ki_set_ccr(OPER_AY_DI_16()); -} - - -static void m68k_op_move_16_toc_ix(void) -{ - m68ki_set_ccr(OPER_AY_IX_16()); -} - - -static void m68k_op_move_16_toc_aw(void) -{ - m68ki_set_ccr(OPER_AW_16()); -} - - -static void m68k_op_move_16_toc_al(void) -{ - m68ki_set_ccr(OPER_AL_16()); -} - - -static void m68k_op_move_16_toc_pcdi(void) -{ - m68ki_set_ccr(OPER_PCDI_16()); -} - - -static void m68k_op_move_16_toc_pcix(void) -{ - m68ki_set_ccr(OPER_PCIX_16()); -} - - -static void m68k_op_move_16_toc_i(void) -{ - m68ki_set_ccr(OPER_I_16()); -} - - -static void m68k_op_move_16_frs_d(void) -{ - if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ - { - DY = MASK_OUT_BELOW_16(DY) | m68ki_get_sr(); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_frs_ai(void) -{ - if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ - { - uint ea = EA_AY_AI_16(); - m68ki_write_16(ea, m68ki_get_sr()); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_frs_pi(void) -{ - if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ - { - uint ea = EA_AY_PI_16(); - m68ki_write_16(ea, m68ki_get_sr()); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_frs_pd(void) -{ - if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ - { - uint ea = EA_AY_PD_16(); - m68ki_write_16(ea, m68ki_get_sr()); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_frs_di(void) -{ - if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ - { - uint ea = EA_AY_DI_16(); - m68ki_write_16(ea, m68ki_get_sr()); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_frs_ix(void) -{ - if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ - { - uint ea = EA_AY_IX_16(); - m68ki_write_16(ea, m68ki_get_sr()); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_frs_aw(void) -{ - if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ - { - uint ea = EA_AW_16(); - m68ki_write_16(ea, m68ki_get_sr()); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_frs_al(void) -{ - if(CPU_TYPE_IS_000(CPU_TYPE) || FLAG_S) /* NS990408 */ - { - uint ea = EA_AL_16(); - m68ki_write_16(ea, m68ki_get_sr()); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_d(void) -{ - if(FLAG_S) - { - m68ki_set_sr(DY); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_ai(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_AY_AI_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_pi(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_AY_PI_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_pd(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_AY_PD_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_di(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_AY_DI_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_ix(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_AY_IX_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_aw(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_AW_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_al(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_AL_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_pcdi(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_PCDI_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_pcix(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_PCIX_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_16_tos_i(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_I_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(new_sr); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_32_fru(void) -{ - if(FLAG_S) - { - AY = REG_USP; - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_move_32_tou(void) -{ - if(FLAG_S) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_USP = AY; - return; - } - m68ki_exception_privilege_violation(); -} - - -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_movec_32_cr(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - switch (word2 & 0xfff) - { - case 0x000: /* SFC */ - REG_DA[(word2 >> 12) & 15] = REG_SFC; - return; - case 0x001: /* DFC */ - REG_DA[(word2 >> 12) & 15] = REG_DFC; - return; - case 0x002: /* CACR */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - REG_DA[(word2 >> 12) & 15] = REG_CACR; - return; - } - return; - case 0x800: /* USP */ - REG_DA[(word2 >> 12) & 15] = REG_USP; - return; - case 0x801: /* VBR */ - REG_DA[(word2 >> 12) & 15] = REG_VBR; - return; - case 0x802: /* CAAR */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - REG_DA[(word2 >> 12) & 15] = REG_CAAR; - return; - } - m68ki_exception_illegal(); - break; - case 0x803: /* MSP */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - REG_DA[(word2 >> 12) & 15] = FLAG_M ? REG_SP : REG_MSP; - return; - } - m68ki_exception_illegal(); - return; - case 0x804: /* ISP */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - REG_DA[(word2 >> 12) & 15] = FLAG_M ? REG_ISP : REG_SP; - return; - } - m68ki_exception_illegal(); - return; - case 0x003: /* TC */ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x004: /* ITT0 */ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x005: /* ITT1 */ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x006: /* DTT0 */ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x007: /* DTT1 */ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x805: /* MMUSR */ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x806: /* URP */ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x807: /* SRP */ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - default: - m68ki_exception_illegal(); - return; - } - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_movec_32_rc(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - switch (word2 & 0xfff) - { - case 0x000: /* SFC */ - REG_SFC = REG_DA[(word2 >> 12) & 15] & 7; - return; - case 0x001: /* DFC */ - REG_DFC = REG_DA[(word2 >> 12) & 15] & 7; - return; - case 0x002: /* CACR */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - REG_CACR = REG_DA[(word2 >> 12) & 15]; - } - else - { - /* non 68040 can only set the lower 4 bits (C,CE,F,E) */ - REG_CACR = REG_DA[(word2 >> 12) & 15] & 0x0f; - } - return; - } - m68ki_exception_illegal(); - return; - case 0x800: /* USP */ - REG_USP = REG_DA[(word2 >> 12) & 15]; - return; - case 0x801: /* VBR */ - REG_VBR = REG_DA[(word2 >> 12) & 15]; - return; - case 0x802: /* CAAR */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - REG_CAAR = REG_DA[(word2 >> 12) & 15]; - return; - } - m68ki_exception_illegal(); - return; - case 0x803: /* MSP */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* we are in supervisor mode so just check for M flag */ - if(!FLAG_M) - { - REG_MSP = REG_DA[(word2 >> 12) & 15]; - return; - } - REG_SP = REG_DA[(word2 >> 12) & 15]; - return; - } - m68ki_exception_illegal(); - return; - case 0x804: /* ISP */ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(!FLAG_M) - { - REG_SP = REG_DA[(word2 >> 12) & 15]; - return; - } - REG_ISP = REG_DA[(word2 >> 12) & 15]; - return; - } - m68ki_exception_illegal(); - return; - case 0x003: /* TC */ - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x004: /* ITT0 */ - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x005: /* ITT1 */ - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x006: /* DTT0 */ - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x007: /* DTT1 */ - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x805: /* MMUSR */ - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x806: /* URP */ - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - case 0x807: /* SRP */ - if (CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - /* TODO */ - return; - } - m68ki_exception_illegal(); - return; - default: - m68ki_exception_illegal(); - return; - } - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_movem_16_re_pd(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = AY; - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - ea -= 2; - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[15-i])); - count++; - } - AY = ea; - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_re_ai(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_AI_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_re_di(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_DI_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_re_ix(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_IX_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_re_aw(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AW_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_re_al(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AL_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_32_re_pd(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = AY; - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - ea -= 4; - m68ki_write_16(ea+2, REG_DA[15-i] & 0xFFFF ); - m68ki_write_16(ea, (REG_DA[15-i] >> 16) & 0xFFFF ); - count++; - } - AY = ea; - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_re_ai(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_AI_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_32(ea, REG_DA[i]); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_re_di(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_DI_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_32(ea, REG_DA[i]); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_re_ix(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_IX_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_32(ea, REG_DA[i]); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_re_aw(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AW_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_32(ea, REG_DA[i]); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_re_al(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AL_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - m68ki_write_32(ea, REG_DA[i]); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_16_er_pi(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = AY; - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); - ea += 2; - count++; - } - AY = ea; - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_er_pcdi(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_PCDI_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_pcrel_16(ea))); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_er_pcix(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_PCIX_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_pcrel_16(ea))); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_er_ai(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_AI_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_er_di(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_DI_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_er_ix(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_IX_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_er_aw(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AW_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_16_er_al(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AL_16(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); - ea += 2; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_W); -} - - -static void m68k_op_movem_32_er_pi(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = AY; - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = m68ki_read_32(ea); - ea += 4; - count++; - } - AY = ea; - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_er_pcdi(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_PCDI_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = m68ki_read_pcrel_32(ea); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_er_pcix(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_PCIX_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = m68ki_read_pcrel_32(ea); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_er_ai(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_AI_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = m68ki_read_32(ea); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_er_di(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_DI_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = m68ki_read_32(ea); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_er_ix(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AY_IX_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = m68ki_read_32(ea); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_er_aw(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AW_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = m68ki_read_32(ea); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movem_32_er_al(void) -{ - uint i = 0; - uint register_list = OPER_I_16(); - uint ea = EA_AL_32(); - uint count = 0; - - for(; i < 16; i++) - if(register_list & (1 << i)) - { - REG_DA[i] = m68ki_read_32(ea); - ea += 4; - count++; - } - - USE_CYCLES(count * CYC_MOVEM_L); -} - - -static void m68k_op_movep_16_re(void) -{ - uint ea = EA_AY_DI_16(); - uint src = DX; - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(src >> 8)); - m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src)); -} - - -static void m68k_op_movep_32_re(void) -{ - uint ea = EA_AY_DI_32(); - uint src = DX; - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(src >> 24)); - m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src >> 16)); - m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src >> 8)); - m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src)); -} - - -static void m68k_op_movep_16_er(void) -{ - uint ea = EA_AY_DI_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | ((m68ki_read_8(ea) << 8) + m68ki_read_8(ea + 2)); -} - - -static void m68k_op_movep_32_er(void) -{ - uint ea = EA_AY_DI_32(); - - DX = (m68ki_read_8(ea) << 24) + (m68ki_read_8(ea + 2) << 16) - + (m68ki_read_8(ea + 4) << 8) + m68ki_read_8(ea + 6); -} - - -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_moves_8_ai(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_AI_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_8_pi(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PI_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_8_pi7(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_A7_PI_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_8_pd(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PD_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_8_pd7(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_A7_PD_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_8_di(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_DI_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_8_ix(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_IX_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_8_aw(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AW_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_8_al(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AL_8(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_8_fc(ea, REG_DFC, MASK_OUT_ABOVE_8(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_8(m68ki_read_8_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_8(REG_D[(word2 >> 12) & 7]) | m68ki_read_8_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_16_ai(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_AI_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_16_pi(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PI_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_16_pd(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PD_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_16_di(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_DI_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_16_ix(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_IX_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_16_aw(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AW_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_16_al(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AL_16(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_16_fc(ea, REG_DFC, MASK_OUT_ABOVE_16(REG_DA[(word2 >> 12) & 15])); - return; - } - if(BIT_F(word2)) /* Memory to address register */ - { - REG_A[(word2 >> 12) & 7] = MAKE_INT_16(m68ki_read_16_fc(ea, REG_SFC)); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to data register */ - REG_D[(word2 >> 12) & 7] = MASK_OUT_BELOW_16(REG_D[(word2 >> 12) & 7]) | m68ki_read_16_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_32_ai(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_AI_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to register */ - REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_32_pi(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PI_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to register */ - REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_32_pd(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_PD_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to register */ - REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_32_di(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_DI_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to register */ - REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_32_ix(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AY_IX_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to register */ - REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_32_aw(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AW_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to register */ - REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_moves_32_al(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - if(FLAG_S) - { - uint word2 = OPER_I_16(); - uint ea = EA_AL_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - if(BIT_B(word2)) /* Register to memory */ - { - m68ki_write_32_fc(ea, REG_DFC, REG_DA[(word2 >> 12) & 15]); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - /* Memory to register */ - REG_DA[(word2 >> 12) & 15] = m68ki_read_32_fc(ea, REG_SFC); - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - USE_CYCLES(14); - return; - } - m68ki_exception_privilege_violation(); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_moveq_32(void) -{ - uint res = DX = MAKE_INT_8(MASK_OUT_ABOVE_8(REG_IR)); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_move16_32(void) -{ - uint16 w2 = OPER_I_16(); - int ax = REG_IR & 7; - int ay = (w2 >> 12) & 7; - - m68ki_write_32(REG_A[ay], m68ki_read_32(REG_A[ax])); - m68ki_write_32(REG_A[ay]+4, m68ki_read_32(REG_A[ax]+4)); - m68ki_write_32(REG_A[ay]+8, m68ki_read_32(REG_A[ax]+8)); - m68ki_write_32(REG_A[ay]+12, m68ki_read_32(REG_A[ax]+12)); - - REG_A[ax] += 16; - REG_A[ay] += 16; -} - - -static void m68k_op_muls_16_d(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(DY); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_ai(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_AY_AI_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_pi(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_AY_PI_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_pd(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_AY_PD_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_di(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_AY_DI_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_ix(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_AY_IX_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_aw(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_AW_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_al(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_AL_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_pcdi(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_PCDI_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_pcix(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_PCIX_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_muls_16_i(void) -{ - uint* r_dst = &DX; - uint src = MAKE_INT_16(OPER_I_16()); - uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); - - uint cyc = getMuls68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_d(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_16(DY); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_ai(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_AI_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_pi(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PI_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_pd(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PD_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_di(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_DI_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_ix(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_IX_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_aw(void) -{ - uint* r_dst = &DX; - uint src = OPER_AW_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_al(void) -{ - uint* r_dst = &DX; - uint src = OPER_AL_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_pcdi(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCDI_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_pcix(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCIX_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_mulu_16_i(void) -{ - uint* r_dst = &DX; - uint src = OPER_I_16(); - uint res = src * MASK_OUT_ABOVE_16(*r_dst); - - uint cyc = getMulu68kCycles(src); - USE_CYCLES(cyc); - - *r_dst = res; - - FLAG_Z = res; - FLAG_N = NFLAG_32(res); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_mull_32_d(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = DY; - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = DY; - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_ai(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_AY_AI_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_AY_AI_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_pi(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_AY_PI_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_AY_PI_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_pd(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_AY_PD_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_AY_PD_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_di(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_AY_DI_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_AY_DI_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_ix(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_AY_IX_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_AY_IX_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_aw(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_AW_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_AW_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_al(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_AL_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_AL_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_pcdi(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_PCDI_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_PCDI_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_pcix(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_PCIX_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_PCIX_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} - - -static void m68k_op_mull_32_i(void) -{ -#if M68K_USE_64_BIT - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint64 src = OPER_I_32(); - uint64 dst = REG_D[(word2 >> 12) & 7]; - uint64 res; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - res = (sint64)((sint32)src) * (sint64)((sint32)dst); - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = ((sint64)res != (sint32)res)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - - res = src * dst; - if(!BIT_A(word2)) - { - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_N = NFLAG_32(res); - FLAG_V = (res > 0xffffffff)<<7; - REG_D[(word2 >> 12) & 7] = FLAG_Z; - return; - } - FLAG_Z = MASK_OUT_ABOVE_32(res) | (res>>32); - FLAG_N = NFLAG_64(res); - FLAG_V = VFLAG_CLEAR; - REG_D[word2 & 7] = (res >> 32); - REG_D[(word2 >> 12) & 7] = MASK_OUT_ABOVE_32(res); - return; - } - m68ki_exception_illegal(); - -#else - - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint word2 = OPER_I_16(); - uint src = OPER_I_32(); - uint dst = REG_D[(word2 >> 12) & 7]; - uint neg = GET_MSB_32(src ^ dst); - uint src1; - uint src2; - uint dst1; - uint dst2; - uint r1; - uint r2; - uint r3; - uint r4; - uint lo; - uint hi; - - FLAG_C = CFLAG_CLEAR; - - if(BIT_B(word2)) /* signed */ - { - if(GET_MSB_32(src)) - src = (uint)MASK_OUT_ABOVE_32(-(sint)src); - if(GET_MSB_32(dst)) - dst = (uint)MASK_OUT_ABOVE_32(-(sint)dst); - } - - src1 = MASK_OUT_ABOVE_16(src); - src2 = src>>16; - dst1 = MASK_OUT_ABOVE_16(dst); - dst2 = dst>>16; - - - r1 = src1 * dst1; - r2 = src1 * dst2; - r3 = src2 * dst1; - r4 = src2 * dst2; - - lo = r1 + (MASK_OUT_ABOVE_16(r2)<<16) + (MASK_OUT_ABOVE_16(r3)<<16); - hi = r4 + (r2>>16) + (r3>>16) + (((r1>>16) + MASK_OUT_ABOVE_16(r2) + MASK_OUT_ABOVE_16(r3)) >> 16); - - if(BIT_B(word2) && neg) - { - hi = (uint)MASK_OUT_ABOVE_32((-(sint)hi) - (lo != 0)); - lo = (uint)MASK_OUT_ABOVE_32(-(sint)lo); - } - - if(BIT_A(word2)) - { - REG_D[word2 & 7] = hi; - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(hi); - FLAG_Z = hi | lo; - FLAG_V = VFLAG_CLEAR; - return; - } - - REG_D[(word2 >> 12) & 7] = lo; - FLAG_N = NFLAG_32(lo); - FLAG_Z = lo; - if(BIT_B(word2)) - FLAG_V = (!((GET_MSB_32(lo) && hi == 0xffffffff) || (!GET_MSB_32(lo) && !hi)))<<7; - else - FLAG_V = (hi != 0) << 7; - return; - } - m68ki_exception_illegal(); - -#endif -} -#endif - - -static void m68k_op_nbcd_8_d(void) -{ - uint* r_dst = &DY; - uint dst = *r_dst; - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_di(void) -{ - uint ea = EA_AY_DI_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_aw(void) -{ - uint ea = EA_AW_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_nbcd_8_al(void) -{ - uint ea = EA_AL_8(); - uint dst = m68ki_read_8(ea); - uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); - - if(res != 0x9a) - { - FLAG_V = ~res; /* Undefined V behavior */ - - if((res & 0x0f) == 0xa) - res = (res & 0xf0) + 0x10; - - res = MASK_OUT_ABOVE_8(res); - - FLAG_V &= res; /* Undefined V behavior part II */ - - m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); - - FLAG_Z |= res; - FLAG_C = CFLAG_SET; - FLAG_X = XFLAG_SET; - } - else - { - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - FLAG_X = XFLAG_CLEAR; - } - FLAG_N = NFLAG_8(res); /* Undefined N behavior */ -} - - -static void m68k_op_neg_8_d(void) -{ - uint* r_dst = &DY; - uint res = 0 - MASK_OUT_ABOVE_8(*r_dst); - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = *r_dst & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_neg_8_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_8_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_8_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_8_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_8_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_8_di(void) -{ - uint ea = EA_AY_DI_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_8_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_8_aw(void) -{ - uint ea = EA_AW_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_8_al(void) -{ - uint ea = EA_AL_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_8(res); - FLAG_C = FLAG_X = CFLAG_8(res); - FLAG_V = src & res; - FLAG_Z = MASK_OUT_ABOVE_8(res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_neg_16_d(void) -{ - uint* r_dst = &DY; - uint res = 0 - MASK_OUT_ABOVE_16(*r_dst); - - FLAG_N = NFLAG_16(res); - FLAG_C = FLAG_X = CFLAG_16(res); - FLAG_V = (*r_dst & res)>>8; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_neg_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_16(res); - FLAG_C = FLAG_X = CFLAG_16(res); - FLAG_V = (src & res)>>8; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_neg_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_16(res); - FLAG_C = FLAG_X = CFLAG_16(res); - FLAG_V = (src & res)>>8; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_neg_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_16(res); - FLAG_C = FLAG_X = CFLAG_16(res); - FLAG_V = (src & res)>>8; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_neg_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_16(res); - FLAG_C = FLAG_X = CFLAG_16(res); - FLAG_V = (src & res)>>8; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_neg_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_16(res); - FLAG_C = FLAG_X = CFLAG_16(res); - FLAG_V = (src & res)>>8; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_neg_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_16(res); - FLAG_C = FLAG_X = CFLAG_16(res); - FLAG_V = (src & res)>>8; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_neg_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_16(res); - FLAG_C = FLAG_X = CFLAG_16(res); - FLAG_V = (src & res)>>8; - FLAG_Z = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_neg_32_d(void) -{ - uint* r_dst = &DY; - uint res = 0 - *r_dst; - - FLAG_N = NFLAG_32(res); - FLAG_C = FLAG_X = CFLAG_SUB_32(*r_dst, 0, res); - FLAG_V = (*r_dst & res)>>24; - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_neg_32_ai(void) -{ - uint ea = EA_AY_AI_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_32(res); - FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_neg_32_pi(void) -{ - uint ea = EA_AY_PI_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_32(res); - FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_neg_32_pd(void) -{ - uint ea = EA_AY_PD_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_32(res); - FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_neg_32_di(void) -{ - uint ea = EA_AY_DI_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_32(res); - FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_neg_32_ix(void) -{ - uint ea = EA_AY_IX_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_32(res); - FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_neg_32_aw(void) -{ - uint ea = EA_AW_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_32(res); - FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_neg_32_al(void) -{ - uint ea = EA_AL_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - src; - - FLAG_N = NFLAG_32(res); - FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - FLAG_Z = MASK_OUT_ABOVE_32(res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_negx_8_d(void) -{ - uint* r_dst = &DY; - uint res = 0 - MASK_OUT_ABOVE_8(*r_dst) - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = *r_dst & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; -} - - -static void m68k_op_negx_8_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_8_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_8_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_8_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_8_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_8_di(void) -{ - uint ea = EA_AY_DI_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_8_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_8_aw(void) -{ - uint ea = EA_AW_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_8_al(void) -{ - uint ea = EA_AL_8(); - uint src = m68ki_read_8(ea); - uint res = 0 - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = src & res; - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_negx_16_d(void) -{ - uint* r_dst = &DY; - uint res = 0 - MASK_OUT_ABOVE_16(*r_dst) - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = (*r_dst & res)>>8; - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; -} - - -static void m68k_op_negx_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = (src & res)>>8; - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_negx_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = (src & res)>>8; - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_negx_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = (src & res)>>8; - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_negx_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = (src & res)>>8; - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_negx_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = (src & res)>>8; - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_negx_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = (src & res)>>8; - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_negx_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = (src & res)>>8; - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_negx_32_d(void) -{ - uint* r_dst = &DY; - uint res = 0 - MASK_OUT_ABOVE_32(*r_dst) - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(*r_dst, 0, res); - FLAG_V = (*r_dst & res)>>24; - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - *r_dst = res; -} - - -static void m68k_op_negx_32_ai(void) -{ - uint ea = EA_AY_AI_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_negx_32_pi(void) -{ - uint ea = EA_AY_PI_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_negx_32_pd(void) -{ - uint ea = EA_AY_PD_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_negx_32_di(void) -{ - uint ea = EA_AY_DI_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_negx_32_ix(void) -{ - uint ea = EA_AY_IX_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_negx_32_aw(void) -{ - uint ea = EA_AW_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_negx_32_al(void) -{ - uint ea = EA_AL_32(); - uint src = m68ki_read_32(ea); - uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); - FLAG_V = (src & res)>>24; - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_nop(void) -{ - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ -} - - -static void m68k_op_not_8_d(void) -{ - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_8(~*r_dst); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_di(void) -{ - uint ea = EA_AY_DI_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_aw(void) -{ - uint ea = EA_AW_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_8_al(void) -{ - uint ea = EA_AL_8(); - uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_16_d(void) -{ - uint* r_dst = &DY; - uint res = MASK_OUT_ABOVE_16(~*r_dst); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_16_aw(void) -{ - uint ea = EA_AW_16(); - uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_16_al(void) -{ - uint ea = EA_AL_16(); - uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_32_d(void) -{ - uint* r_dst = &DY; - uint res = *r_dst = MASK_OUT_ABOVE_32(~*r_dst); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_32_ai(void) -{ - uint ea = EA_AY_AI_32(); - uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_32_pi(void) -{ - uint ea = EA_AY_PI_32(); - uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_32_pd(void) -{ - uint ea = EA_AY_PD_32(); - uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_32_di(void) -{ - uint ea = EA_AY_DI_32(); - uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_32_ix(void) -{ - uint ea = EA_AY_IX_32(); - uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_32_aw(void) -{ - uint ea = EA_AW_32(); - uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_not_32_al(void) -{ - uint ea = EA_AL_32(); - uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_d(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= MASK_OUT_ABOVE_8(DY))); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_ai(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_AI_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_pi(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_PI_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_pi7(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_A7_PI_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_pd(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_PD_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_pd7(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_A7_PD_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_di(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_DI_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_ix(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_IX_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_aw(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_AW_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_al(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_AL_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_pcdi(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_PCDI_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_pcix(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_PCIX_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_er_i(void) -{ - uint res = MASK_OUT_ABOVE_8((DX |= OPER_I_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_d(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= MASK_OUT_ABOVE_16(DY))); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_ai(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_AI_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_pi(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_PI_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_pd(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_PD_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_di(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_DI_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_ix(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_IX_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_aw(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_AW_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_al(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_AL_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_pcdi(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_PCDI_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_pcix(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_PCIX_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_er_i(void) -{ - uint res = MASK_OUT_ABOVE_16((DX |= OPER_I_16())); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_d(void) -{ - uint res = DX |= DY; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_ai(void) -{ - uint res = DX |= OPER_AY_AI_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_pi(void) -{ - uint res = DX |= OPER_AY_PI_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_pd(void) -{ - uint res = DX |= OPER_AY_PD_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_di(void) -{ - uint res = DX |= OPER_AY_DI_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_ix(void) -{ - uint res = DX |= OPER_AY_IX_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_aw(void) -{ - uint res = DX |= OPER_AW_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_al(void) -{ - uint res = DX |= OPER_AL_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_pcdi(void) -{ - uint res = DX |= OPER_PCDI_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_pcix(void) -{ - uint res = DX |= OPER_PCIX_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_er_i(void) -{ - uint res = DX |= OPER_I_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_di(void) -{ - uint ea = EA_AY_DI_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_aw(void) -{ - uint ea = EA_AW_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_8_re_al(void) -{ - uint ea = EA_AL_8(); - uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_re_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_re_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_re_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_re_di(void) -{ - uint ea = EA_AY_DI_16(); - uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_re_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_re_aw(void) -{ - uint ea = EA_AW_16(); - uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_16_re_al(void) -{ - uint ea = EA_AL_16(); - uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_re_ai(void) -{ - uint ea = EA_AY_AI_32(); - uint res = DX | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_re_pi(void) -{ - uint ea = EA_AY_PI_32(); - uint res = DX | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_re_pd(void) -{ - uint ea = EA_AY_PD_32(); - uint res = DX | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_re_di(void) -{ - uint ea = EA_AY_DI_32(); - uint res = DX | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_re_ix(void) -{ - uint ea = EA_AY_IX_32(); - uint res = DX | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_re_aw(void) -{ - uint ea = EA_AW_32(); - uint res = DX | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_or_32_re_al(void) -{ - uint ea = EA_AL_32(); - uint res = DX | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_d(void) -{ - uint res = MASK_OUT_ABOVE_8((DY |= OPER_I_8())); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_ai(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_AI_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_pi(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PI_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_pi7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PI_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_pd(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PD_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_pd7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PD_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_di(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_DI_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_ix(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_IX_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_aw(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AW_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_8_al(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AL_8(); - uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); - - m68ki_write_8(ea, res); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY |= OPER_I_16()); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_ai(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_AI_16(); - uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_pi(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PI_16(); - uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_pd(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PD_16(); - uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_di(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_DI_16(); - uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_ix(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_IX_16(); - uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_aw(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AW_16(); - uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_al(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AL_16(); - uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_32_d(void) -{ - uint res = DY |= OPER_I_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_32_ai(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_AI_32(); - uint res = src | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_32_pi(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PI_32(); - uint res = src | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_32_pd(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PD_32(); - uint res = src | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_32_di(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_DI_32(); - uint res = src | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_32_ix(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_IX_32(); - uint res = src | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_32_aw(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AW_32(); - uint res = src | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_32_al(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AL_32(); - uint res = src | m68ki_read_32(ea); - - m68ki_write_32(ea, res); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ori_16_toc(void) -{ - m68ki_set_ccr(m68ki_get_ccr() | OPER_I_16()); -} - - -static void m68k_op_ori_16_tos(void) -{ - if(FLAG_S) - { - uint src = OPER_I_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_sr(m68ki_get_sr() | src); - return; - } - m68ki_exception_privilege_violation(); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_pack_16_rr(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Note: DX and DY are reversed in Motorola's docs */ - uint src = DY + OPER_I_16(); - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | ((src >> 4) & 0x00f0) | (src & 0x000f); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_pack_16_mm_ax7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Note: AX and AY are reversed in Motorola's docs */ - uint ea_src = EA_AY_PD_8(); - uint src = m68ki_read_8(ea_src); - ea_src = EA_AY_PD_8(); - src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16(); - - m68ki_write_8(EA_A7_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f)); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_pack_16_mm_ay7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Note: AX and AY are reversed in Motorola's docs */ - uint ea_src = EA_A7_PD_8(); - uint src = m68ki_read_8(ea_src); - ea_src = EA_A7_PD_8(); - src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16(); - - m68ki_write_8(EA_AX_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f)); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_pack_16_mm_axy7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint ea_src = EA_A7_PD_8(); - uint src = m68ki_read_8(ea_src); - ea_src = EA_A7_PD_8(); - src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16(); - - m68ki_write_8(EA_A7_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f)); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_pack_16_mm(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Note: AX and AY are reversed in Motorola's docs */ - uint ea_src = EA_AY_PD_8(); - uint src = m68ki_read_8(ea_src); - ea_src = EA_AY_PD_8(); - src = ((src << 8) | m68ki_read_8(ea_src)) + OPER_I_16(); - - m68ki_write_8(EA_AX_PD_8(), ((src >> 4) & 0x00f0) | (src & 0x000f)); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_pea_32_ai(void) -{ - uint ea = EA_AY_AI_32(); - - m68ki_push_32(ea); -} - - -static void m68k_op_pea_32_di(void) -{ - uint ea = EA_AY_DI_32(); - - m68ki_push_32(ea); -} - - -static void m68k_op_pea_32_ix(void) -{ - uint ea = EA_AY_IX_32(); - - m68ki_push_32(ea); -} - - -static void m68k_op_pea_32_aw(void) -{ - uint ea = EA_AW_32(); - - m68ki_push_32(ea); -} - - -static void m68k_op_pea_32_al(void) -{ - uint ea = EA_AL_32(); - - m68ki_push_32(ea); -} - - -static void m68k_op_pea_32_pcdi(void) -{ - uint ea = EA_PCDI_32(); - - m68ki_push_32(ea); -} - - -static void m68k_op_pea_32_pcix(void) -{ - uint ea = EA_PCIX_32(); - - m68ki_push_32(ea); -} - - -#if M68K_EMULATE_040 -static void m68k_op_pflush_32(void) -{ - if(CPU_TYPE_IS_040_PLUS(CPU_TYPE)) - { - // Nothing to do, unless address translation cache is emulated - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_reset(void) -{ - if(FLAG_S) - { - m68ki_output_reset(); /* auto-disable (see m68kcpu.h) */ - USE_CYCLES(CYC_RESET); - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_ror_8_s(void) -{ - uint* r_dst = &DY; - uint orig_shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint shift = orig_shift & 7; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = ROR_8(src, shift); - - if(orig_shift != 0) - USE_CYCLES(orig_shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = src << (9-orig_shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = ROR_16(src, shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src << (9-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_32_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint64 src = *r_dst; - uint res = ROR_32(src, shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = src << (9-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_8_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - uint shift = orig_shift & 7; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = ROR_8(src, shift); - - if(orig_shift != 0) - { - USE_CYCLES(orig_shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - FLAG_C = src << (8-((shift-1)&7)); - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_8(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - uint shift = orig_shift & 15; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = ROR_16(src, shift); - - if(orig_shift != 0) - { - USE_CYCLES(orig_shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - FLAG_C = (src >> ((shift - 1) & 15)) << 8; - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_16(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_32_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - uint shift = orig_shift & 31; - uint64 src = *r_dst; - uint res = ROR_32(src, shift); - - if(orig_shift != 0) - { - USE_CYCLES(orig_shift * CYC_SHIFT); - - *r_dst = res; - FLAG_C = (src >> ((shift - 1) & 31)) << 8; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_32(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_16(src, 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_16(src, 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_16(src, 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_16(src, 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_16(src, 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_16(src, 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_ror_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_16(src, 1); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src << 8; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_8_s(void) -{ - uint* r_dst = &DY; - uint orig_shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint shift = orig_shift & 7; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = ROL_8(src, shift); - - if(orig_shift != 0) - USE_CYCLES(orig_shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_C = src << orig_shift; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = ROL_16(src, shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src >> (8-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_32_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint64 src = *r_dst; - uint res = ROL_32(src, shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_C = src >> (24-shift); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_8_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - uint shift = orig_shift & 7; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = ROL_8(src, shift); - - if(orig_shift != 0) - { - USE_CYCLES(orig_shift * CYC_SHIFT); - - if(shift != 0) - { - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - FLAG_C = src << shift; - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - FLAG_C = (src & 1)<<8; - FLAG_N = NFLAG_8(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_8(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - uint shift = orig_shift & 15; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = MASK_OUT_ABOVE_16(ROL_16(src, shift)); - - if(orig_shift != 0) - { - USE_CYCLES(orig_shift * CYC_SHIFT); - - if(shift != 0) - { - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - FLAG_C = (src << shift) >> 8; - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - FLAG_C = (src & 1)<<8; - FLAG_N = NFLAG_16(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_16(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_32_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - uint shift = orig_shift & 31; - uint64 src = *r_dst; - uint res = ROL_32(src, shift); - - if(orig_shift != 0) - { - USE_CYCLES(orig_shift * CYC_SHIFT); - - *r_dst = res; - - FLAG_C = (src >> ((32 - shift) & 0x1f)) << 8; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = CFLAG_CLEAR; - FLAG_N = NFLAG_32(src); - FLAG_Z = src; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_rol_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_C = src >> 7; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_8_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = ROR_9(src | (XFLAG_AS_1() << 8), shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res; - res = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_16_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_32_s(void) -{ -#if M68K_USE_64_BIT - - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint64 src = *r_dst; - uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - res = ROR_33_64(res, shift); - - FLAG_C = FLAG_X = res >> 24; - res = MASK_OUT_ABOVE_32(res); - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - -#else - - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = *r_dst; - uint res = MASK_OUT_ABOVE_32((ROR_33(src, shift) & ~(1 << (32 - shift))) | (XFLAG_AS_1() << (32 - shift))); - uint new_x_flag = src & (1 << (shift - 1)); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = res; - - FLAG_C = FLAG_X = (new_x_flag != 0)<<8; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - -#endif -} - - -static void m68k_op_roxr_8_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - - if(orig_shift != 0) - { - uint shift = orig_shift % 9; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = ROR_9(src | (XFLAG_AS_1() << 8), shift); - - USE_CYCLES(orig_shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res; - res = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = FLAG_X; - FLAG_N = NFLAG_8(*r_dst); - FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_16_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - - if(orig_shift != 0) - { - uint shift = orig_shift % 17; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), shift); - - USE_CYCLES(orig_shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = FLAG_X; - FLAG_N = NFLAG_16(*r_dst); - FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_32_r(void) -{ -#if M68K_USE_64_BIT - - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - - if(orig_shift != 0) - { - uint shift = orig_shift % 33; - uint64 src = *r_dst; - uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); - - res = ROR_33_64(res, shift); - - USE_CYCLES(orig_shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res >> 24; - res = MASK_OUT_ABOVE_32(res); - - *r_dst = res; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = FLAG_X; - FLAG_N = NFLAG_32(*r_dst); - FLAG_Z = *r_dst; - FLAG_V = VFLAG_CLEAR; - -#else - - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - uint shift = orig_shift % 33; - uint src = *r_dst; - uint res = MASK_OUT_ABOVE_32((ROR_33(src, shift) & ~(1 << (32 - shift))) | (XFLAG_AS_1() << (32 - shift))); - uint new_x_flag = src & (1 << (shift - 1)); - - if(orig_shift != 0) - USE_CYCLES(orig_shift * CYC_SHIFT); - - if(shift != 0) - { - *r_dst = res; - FLAG_X = (new_x_flag != 0)<<8; - } - else - res = src; - FLAG_C = FLAG_X; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - -#endif -} - - -static void m68k_op_roxr_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxr_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_8_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = ROL_9(src | (XFLAG_AS_1() << 8), shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res; - res = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_16_s(void) -{ - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), shift); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_32_s(void) -{ -#if M68K_USE_64_BIT - - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint64 src = *r_dst; - uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - res = ROL_33_64(res, shift); - - FLAG_C = FLAG_X = res >> 24; - res = MASK_OUT_ABOVE_32(res); - - *r_dst = res; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - -#else - - uint* r_dst = &DY; - uint shift = (((REG_IR >> 9) - 1) & 7) + 1; - uint src = *r_dst; - uint res = MASK_OUT_ABOVE_32((ROL_33(src, shift) & ~(1 << (shift - 1))) | (XFLAG_AS_1() << (shift - 1))); - uint new_x_flag = src & (1 << (32 - shift)); - - if(shift != 0) - USE_CYCLES(shift * CYC_SHIFT); - - *r_dst = res; - - FLAG_C = FLAG_X = (new_x_flag != 0)<<8; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - -#endif -} - - -static void m68k_op_roxl_8_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - - - if(orig_shift != 0) - { - uint shift = orig_shift % 9; - uint src = MASK_OUT_ABOVE_8(*r_dst); - uint res = ROL_9(src | (XFLAG_AS_1() << 8), shift); - - USE_CYCLES(orig_shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res; - res = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = FLAG_X; - FLAG_N = NFLAG_8(*r_dst); - FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_16_r(void) -{ - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - - if(orig_shift != 0) - { - uint shift = orig_shift % 17; - uint src = MASK_OUT_ABOVE_16(*r_dst); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), shift); - - USE_CYCLES(orig_shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = FLAG_X; - FLAG_N = NFLAG_16(*r_dst); - FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_32_r(void) -{ -#if M68K_USE_64_BIT - - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - - if(orig_shift != 0) - { - uint shift = orig_shift % 33; - uint64 src = *r_dst; - uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); - - res = ROL_33_64(res, shift); - - USE_CYCLES(orig_shift * CYC_SHIFT); - - FLAG_C = FLAG_X = res >> 24; - res = MASK_OUT_ABOVE_32(res); - - *r_dst = res; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - return; - } - - FLAG_C = FLAG_X; - FLAG_N = NFLAG_32(*r_dst); - FLAG_Z = *r_dst; - FLAG_V = VFLAG_CLEAR; - -#else - - uint* r_dst = &DY; - uint orig_shift = DX & 0x3f; - uint shift = orig_shift % 33; - uint src = *r_dst; - uint res = MASK_OUT_ABOVE_32((ROL_33(src, shift) & ~(1 << (shift - 1))) | (XFLAG_AS_1() << (shift - 1))); - uint new_x_flag = src & (1 << (32 - shift)); - - if(orig_shift != 0) - USE_CYCLES(orig_shift * CYC_SHIFT); - - if(shift != 0) - { - *r_dst = res; - FLAG_X = (new_x_flag != 0)<<8; - } - else - res = src; - FLAG_C = FLAG_X; - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - -#endif -} - - -static void m68k_op_roxl_16_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = m68ki_read_16(ea); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_16_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = m68ki_read_16(ea); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_16_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = m68ki_read_16(ea); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_16_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = m68ki_read_16(ea); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_16_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = m68ki_read_16(ea); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_16_aw(void) -{ - uint ea = EA_AW_16(); - uint src = m68ki_read_16(ea); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_roxl_16_al(void) -{ - uint ea = EA_AL_16(); - uint src = m68ki_read_16(ea); - uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); - - FLAG_C = FLAG_X = res >> 8; - res = MASK_OUT_ABOVE_16(res); - - m68ki_write_16(ea, res); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; -} - - -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_rtd_32(void) -{ - if(CPU_TYPE_IS_010_PLUS(CPU_TYPE)) - { - uint new_pc = m68ki_pull_32(); - - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16())); - m68ki_jump(new_pc); - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_rte_32(void) -{ - if(FLAG_S) - { - uint new_sr; - uint new_pc; - uint format_word; - - m68ki_rte_callback(); /* auto-disable (see m68kcpu.h) */ - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - - if(CPU_TYPE_IS_000(CPU_TYPE)) - { - new_sr = m68ki_pull_16(); - new_pc = m68ki_pull_32(); - m68ki_jump(new_pc); - m68ki_set_sr(new_sr); - - CPU_INSTR_MODE = INSTRUCTION_YES; - CPU_RUN_MODE = RUN_MODE_NORMAL; - - return; - } - - if(CPU_TYPE_IS_010(CPU_TYPE)) - { - format_word = m68ki_read_16(REG_A[7]+6) >> 12; - if(format_word == 0) - { - new_sr = m68ki_pull_16(); - new_pc = m68ki_pull_32(); - m68ki_fake_pull_16(); /* format word */ - m68ki_jump(new_pc); - m68ki_set_sr(new_sr); - CPU_INSTR_MODE = INSTRUCTION_YES; - CPU_RUN_MODE = RUN_MODE_NORMAL; - return; - } - CPU_INSTR_MODE = INSTRUCTION_YES; - CPU_RUN_MODE = RUN_MODE_NORMAL; - /* Not handling bus fault (9) */ - m68ki_exception_format_error(); - return; - } - - /* Otherwise it's 020 */ -rte_loop: - format_word = m68ki_read_16(REG_A[7]+6) >> 12; - switch(format_word) - { - case 0: /* Normal */ - new_sr = m68ki_pull_16(); - new_pc = m68ki_pull_32(); - m68ki_fake_pull_16(); /* format word */ - m68ki_jump(new_pc); - m68ki_set_sr(new_sr); - CPU_INSTR_MODE = INSTRUCTION_YES; - CPU_RUN_MODE = RUN_MODE_NORMAL; - return; - case 1: /* Throwaway */ - new_sr = m68ki_pull_16(); - m68ki_fake_pull_32(); /* program counter */ - m68ki_fake_pull_16(); /* format word */ - m68ki_set_sr_noint(new_sr); - goto rte_loop; - case 2: /* Trap */ - new_sr = m68ki_pull_16(); - new_pc = m68ki_pull_32(); - m68ki_fake_pull_16(); /* format word */ - m68ki_fake_pull_32(); /* address */ - m68ki_jump(new_pc); - m68ki_set_sr(new_sr); - CPU_INSTR_MODE = INSTRUCTION_YES; - CPU_RUN_MODE = RUN_MODE_NORMAL; - return; - } - /* Not handling long or short bus fault */ - CPU_INSTR_MODE = INSTRUCTION_YES; - CPU_RUN_MODE = RUN_MODE_NORMAL; - m68ki_exception_format_error(); - return; - } - m68ki_exception_privilege_violation(); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_rtm_32(void) -{ - if(CPU_TYPE_IS_020_VARIANT(CPU_TYPE)) - { - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - M68K_DO_LOG((M68K_LOG_FILEHANDLE "%s at %08x: called unimplemented instruction %04x (%s)\n", - m68ki_cpu_names[CPU_TYPE], ADDRESS_68K(REG_PC - 2), REG_IR, - m68k_disassemble_quick(ADDRESS_68K(REG_PC - 2)))); - return; - } - m68ki_exception_illegal(); -} -#endif - -static void m68k_op_rtr_32(void) -{ - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_set_ccr(m68ki_pull_16()); - m68ki_jump(m68ki_pull_32()); -} - - -static void m68k_op_rts_32(void) -{ - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - m68ki_jump(m68ki_pull_32()); -} - - -static void m68k_op_sbcd_8_rr(void) -{ - uint* r_dst = &DX; - uint src = DY; - uint dst = *r_dst; - uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); - -// FLAG_V = ~res; /* Undefined V behavior */ - FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to assume cleared. */ - - if(res > 9) - res -= 6; - res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); - if(res > 0x99) - { - res += 0xa0; - FLAG_X = FLAG_C = CFLAG_SET; - FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ - } - else - FLAG_N = FLAG_X = FLAG_C = 0; - - res = MASK_OUT_ABOVE_8(res); - -// FLAG_V &= res; /* Undefined V behavior part II */ -// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - FLAG_Z |= res; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; -} - - -static void m68k_op_sbcd_8_mm_ax7(void) -{ - uint src = OPER_AY_PD_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); - -// FLAG_V = ~res; /* Undefined V behavior */ - FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ - - if(res > 9) - res -= 6; - res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); - if(res > 0x99) - { - res += 0xa0; - FLAG_X = FLAG_C = CFLAG_SET; - FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ - } - else - FLAG_N = FLAG_X = FLAG_C = 0; - - res = MASK_OUT_ABOVE_8(res); - -// FLAG_V &= res; /* Undefined V behavior part II */ -// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_sbcd_8_mm_ay7(void) -{ - uint src = OPER_A7_PD_8(); - uint ea = EA_AX_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); - -// FLAG_V = ~res; /* Undefined V behavior */ - FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ - - if(res > 9) - res -= 6; - res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); - if(res > 0x99) - { - res += 0xa0; - FLAG_X = FLAG_C = CFLAG_SET; - FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ - } - else - FLAG_N = FLAG_X = FLAG_C = 0; - - res = MASK_OUT_ABOVE_8(res); - -// FLAG_V &= res; /* Undefined V behavior part II */ -// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_sbcd_8_mm_axy7(void) -{ - uint src = OPER_A7_PD_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); - -// FLAG_V = ~res; /* Undefined V behavior */ - FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ - - if(res > 9) - res -= 6; - res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); - if(res > 0x99) - { - res += 0xa0; - FLAG_X = FLAG_C = CFLAG_SET; - FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ - } - else - FLAG_N = FLAG_X = FLAG_C = 0; - - res = MASK_OUT_ABOVE_8(res); - -// FLAG_V &= res; /* Undefined V behavior part II */ -// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_sbcd_8_mm(void) -{ - uint src = OPER_AY_PD_8(); - uint ea = EA_AX_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); - -// FLAG_V = ~res; /* Undefined V behavior */ - FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ - - if(res > 9) - res -= 6; - res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); - if(res > 0x99) - { - res += 0xa0; - FLAG_X = FLAG_C = CFLAG_SET; - FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ - } - else - FLAG_N = FLAG_X = FLAG_C = 0; - - res = MASK_OUT_ABOVE_8(res); - -// FLAG_V &= res; /* Undefined V behavior part II */ -// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_st_8_d(void) -{ - DY |= 0xff; -} - - -static void m68k_op_st_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), 0xff); -} - - -static void m68k_op_st_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), 0xff); -} - - -static void m68k_op_st_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), 0xff); -} - - -static void m68k_op_st_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), 0xff); -} - - -static void m68k_op_st_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), 0xff); -} - - -static void m68k_op_st_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), 0xff); -} - - -static void m68k_op_st_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), 0xff); -} - - -static void m68k_op_st_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), 0xff); -} - - -static void m68k_op_st_8_al(void) -{ - m68ki_write_8(EA_AL_8(), 0xff); -} - - -static void m68k_op_sf_8_d(void) -{ - DY &= 0xffffff00; -} - - -static void m68k_op_sf_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), 0); -} - - -static void m68k_op_sf_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), 0); -} - - -static void m68k_op_sf_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), 0); -} - - -static void m68k_op_sf_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), 0); -} - - -static void m68k_op_sf_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), 0); -} - - -static void m68k_op_sf_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), 0); -} - - -static void m68k_op_sf_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), 0); -} - - -static void m68k_op_sf_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), 0); -} - - -static void m68k_op_sf_8_al(void) -{ - m68ki_write_8(EA_AL_8(), 0); -} - - -static void m68k_op_shi_8_d(void) -{ - if(COND_HI()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_sls_8_d(void) -{ - if(COND_LS()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_scc_8_d(void) -{ - if(COND_CC()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_scs_8_d(void) -{ - if(COND_CS()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_sne_8_d(void) -{ - if(COND_NE()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_seq_8_d(void) -{ - if(COND_EQ()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_svc_8_d(void) -{ - if(COND_VC()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_svs_8_d(void) -{ - if(COND_VS()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_spl_8_d(void) -{ - if(COND_PL()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_smi_8_d(void) -{ - if(COND_MI()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_sge_8_d(void) -{ - if(COND_GE()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_slt_8_d(void) -{ - if(COND_LT()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_sgt_8_d(void) -{ - if(COND_GT()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_sle_8_d(void) -{ - if(COND_LE()) - { - DY |= 0xff; - USE_CYCLES(CYC_SCC_R_TRUE); - return; - } - DY &= 0xffffff00; -} - - -static void m68k_op_shi_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_shi_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_shi_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_shi_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_shi_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_shi_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_shi_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_shi_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_shi_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_HI() ? 0xff : 0); -} - - -static void m68k_op_sls_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_sls_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_sls_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_sls_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_sls_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_sls_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_sls_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_sls_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_sls_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_LS() ? 0xff : 0); -} - - -static void m68k_op_scc_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scc_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scc_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scc_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scc_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scc_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scc_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scc_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scc_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_CC() ? 0xff : 0); -} - - -static void m68k_op_scs_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_scs_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_scs_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_scs_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_scs_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_scs_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_scs_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_scs_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_scs_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_CS() ? 0xff : 0); -} - - -static void m68k_op_sne_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_sne_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_sne_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_sne_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_sne_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_sne_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_sne_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_sne_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_sne_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_NE() ? 0xff : 0); -} - - -static void m68k_op_seq_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_seq_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_seq_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_seq_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_seq_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_seq_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_seq_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_seq_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_seq_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_EQ() ? 0xff : 0); -} - - -static void m68k_op_svc_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svc_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svc_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svc_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svc_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svc_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svc_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svc_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svc_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_VC() ? 0xff : 0); -} - - -static void m68k_op_svs_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_svs_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_svs_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_svs_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_svs_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_svs_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_svs_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_svs_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_svs_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_VS() ? 0xff : 0); -} - - -static void m68k_op_spl_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_spl_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_spl_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_spl_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_spl_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_spl_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_spl_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_spl_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_spl_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_PL() ? 0xff : 0); -} - - -static void m68k_op_smi_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_smi_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_smi_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_smi_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_smi_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_smi_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_smi_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_smi_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_smi_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_MI() ? 0xff : 0); -} - - -static void m68k_op_sge_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_sge_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_sge_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_sge_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_sge_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_sge_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_sge_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_sge_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_sge_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_GE() ? 0xff : 0); -} - - -static void m68k_op_slt_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_slt_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_slt_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_slt_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_slt_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_slt_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_slt_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_slt_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_slt_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_LT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sgt_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_GT() ? 0xff : 0); -} - - -static void m68k_op_sle_8_ai(void) -{ - m68ki_write_8(EA_AY_AI_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_sle_8_pi(void) -{ - m68ki_write_8(EA_AY_PI_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_sle_8_pi7(void) -{ - m68ki_write_8(EA_A7_PI_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_sle_8_pd(void) -{ - m68ki_write_8(EA_AY_PD_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_sle_8_pd7(void) -{ - m68ki_write_8(EA_A7_PD_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_sle_8_di(void) -{ - m68ki_write_8(EA_AY_DI_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_sle_8_ix(void) -{ - m68ki_write_8(EA_AY_IX_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_sle_8_aw(void) -{ - m68ki_write_8(EA_AW_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_sle_8_al(void) -{ - m68ki_write_8(EA_AL_8(), COND_LE() ? 0xff : 0); -} - - -static void m68k_op_stop(void) -{ - if(FLAG_S) - { - uint new_sr = OPER_I_16(); - m68ki_trace_t0(); /* auto-disable (see m68kcpu.h) */ - CPU_STOPPED |= STOP_LEVEL_STOP; - m68ki_set_sr(new_sr); - //m68ki_remaining_cycles = 0; - return; - } - m68ki_exception_privilege_violation(); -} - - -static void m68k_op_sub_8_er_d(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_8(DY); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_ai(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_AI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_pi(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_pi7(void) -{ - uint* r_dst = &DX; - uint src = OPER_A7_PI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_pd(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PD_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_pd7(void) -{ - uint* r_dst = &DX; - uint src = OPER_A7_PD_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_di(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_DI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_ix(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_IX_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_aw(void) -{ - uint* r_dst = &DX; - uint src = OPER_AW_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_al(void) -{ - uint* r_dst = &DX; - uint src = OPER_AL_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_pcdi(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCDI_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_pcix(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCIX_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_8_er_i(void) -{ - uint* r_dst = &DX; - uint src = OPER_I_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_d(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_16(DY); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_a(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_16(AY); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_ai(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_AI_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_pi(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PI_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_pd(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PD_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_di(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_DI_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_ix(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_IX_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_aw(void) -{ - uint* r_dst = &DX; - uint src = OPER_AW_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_al(void) -{ - uint* r_dst = &DX; - uint src = OPER_AL_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_pcdi(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCDI_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_pcix(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCIX_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_16_er_i(void) -{ - uint* r_dst = &DX; - uint src = OPER_I_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_sub_32_er_d(void) -{ - uint* r_dst = &DX; - uint src = DY; - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_a(void) -{ - uint* r_dst = &DX; - uint src = AY; - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_ai(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_AI_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_pi(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PI_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_pd(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_PD_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_di(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_DI_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_ix(void) -{ - uint* r_dst = &DX; - uint src = OPER_AY_IX_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_aw(void) -{ - uint* r_dst = &DX; - uint src = OPER_AW_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_al(void) -{ - uint* r_dst = &DX; - uint src = OPER_AL_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_pcdi(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCDI_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_pcix(void) -{ - uint* r_dst = &DX; - uint src = OPER_PCIX_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_32_er_i(void) -{ - uint* r_dst = &DX; - uint src = OPER_I_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_sub_8_re_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_8_re_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_8_re_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_8_re_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_8_re_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_8_re_di(void) -{ - uint ea = EA_AY_DI_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_8_re_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_8_re_aw(void) -{ - uint ea = EA_AW_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_8_re_al(void) -{ - uint ea = EA_AL_8(); - uint src = MASK_OUT_ABOVE_8(DX); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_sub_16_re_ai(void) -{ - uint ea = EA_AY_AI_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_sub_16_re_pi(void) -{ - uint ea = EA_AY_PI_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_sub_16_re_pd(void) -{ - uint ea = EA_AY_PD_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_sub_16_re_di(void) -{ - uint ea = EA_AY_DI_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_sub_16_re_ix(void) -{ - uint ea = EA_AY_IX_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_sub_16_re_aw(void) -{ - uint ea = EA_AW_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_sub_16_re_al(void) -{ - uint ea = EA_AL_16(); - uint src = MASK_OUT_ABOVE_16(DX); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_sub_32_re_ai(void) -{ - uint ea = EA_AY_AI_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_sub_32_re_pi(void) -{ - uint ea = EA_AY_PI_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_sub_32_re_pd(void) -{ - uint ea = EA_AY_PD_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_sub_32_re_di(void) -{ - uint ea = EA_AY_DI_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_sub_32_re_ix(void) -{ - uint ea = EA_AY_IX_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_sub_32_re_aw(void) -{ - uint ea = EA_AW_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_sub_32_re_al(void) -{ - uint ea = EA_AL_32(); - uint src = DX; - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_suba_16_d(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(DY)); -} - - -static void m68k_op_suba_16_a(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(AY)); -} - - -static void m68k_op_suba_16_ai(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_AI_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_pi(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_PI_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_pd(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_PD_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_di(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_DI_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_ix(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AY_IX_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_aw(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AW_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_al(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_AL_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_pcdi(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_PCDI_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_pcix(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_PCIX_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_16_i(void) -{ - uint* r_dst = &AX; - uint src = MAKE_INT_16(OPER_I_16()); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_d(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - DY); -} - - -static void m68k_op_suba_32_a(void) -{ - uint* r_dst = &AX; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - AY); -} - - -static void m68k_op_suba_32_ai(void) -{ - uint* r_dst = &AX; - uint src = OPER_AY_AI_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_pi(void) -{ - uint* r_dst = &AX; - uint src = OPER_AY_PI_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_pd(void) -{ - uint* r_dst = &AX; - uint src = OPER_AY_PD_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_di(void) -{ - uint* r_dst = &AX; - uint src = OPER_AY_DI_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_ix(void) -{ - uint* r_dst = &AX; - uint src = OPER_AY_IX_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_aw(void) -{ - uint* r_dst = &AX; - uint src = OPER_AW_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_al(void) -{ - uint* r_dst = &AX; - uint src = OPER_AL_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_pcdi(void) -{ - uint* r_dst = &AX; - uint src = OPER_PCDI_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_pcix(void) -{ - uint* r_dst = &AX; - uint src = OPER_PCIX_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_suba_32_i(void) -{ - uint* r_dst = &AX; - uint src = OPER_I_32(); - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); -} - - -static void m68k_op_subi_8_d(void) -{ - uint* r_dst = &DY; - uint src = OPER_I_8(); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_subi_8_ai(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_AI_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_8_pi(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_8_pi7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_8_pd(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_8_pd7(void) -{ - uint src = OPER_I_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_8_di(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_DI_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_8_ix(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AY_IX_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_8_aw(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AW_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_8_al(void) -{ - uint src = OPER_I_8(); - uint ea = EA_AL_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subi_16_d(void) -{ - uint* r_dst = &DY; - uint src = OPER_I_16(); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_subi_16_ai(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_AI_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subi_16_pi(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PI_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subi_16_pd(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_PD_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subi_16_di(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_DI_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subi_16_ix(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AY_IX_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subi_16_aw(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AW_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subi_16_al(void) -{ - uint src = OPER_I_16(); - uint ea = EA_AL_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subi_32_d(void) -{ - uint* r_dst = &DY; - uint src = OPER_I_32(); - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_subi_32_ai(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_AI_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subi_32_pi(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PI_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subi_32_pd(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_PD_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subi_32_di(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_DI_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subi_32_ix(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AY_IX_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subi_32_aw(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AW_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subi_32_al(void) -{ - uint src = OPER_I_32(); - uint ea = EA_AL_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_d(void) -{ - uint* r_dst = &DY; - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; -} - - -static void m68k_op_subq_8_ai(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_AI_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_pi(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_pi7(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_A7_PI_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_pd(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_pd7(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_di(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_DI_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_ix(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_IX_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_aw(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AW_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_8_al(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AL_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src; - - FLAG_N = NFLAG_8(res); - FLAG_Z = MASK_OUT_ABOVE_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - m68ki_write_8(ea, FLAG_Z); -} - - -static void m68k_op_subq_16_d(void) -{ - uint* r_dst = &DY; - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; -} - - -static void m68k_op_subq_16_a(void) -{ - uint* r_dst = &AY; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - ((((REG_IR >> 9) - 1) & 7) + 1)); -} - - -static void m68k_op_subq_16_ai(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_AI_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subq_16_pi(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PI_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subq_16_pd(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PD_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subq_16_di(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_DI_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subq_16_ix(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_IX_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subq_16_aw(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AW_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subq_16_al(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AL_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src; - - FLAG_N = NFLAG_16(res); - FLAG_Z = MASK_OUT_ABOVE_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - m68ki_write_16(ea, FLAG_Z); -} - - -static void m68k_op_subq_32_d(void) -{ - uint* r_dst = &DY; - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint dst = *r_dst; - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - *r_dst = FLAG_Z; -} - - -static void m68k_op_subq_32_a(void) -{ - uint* r_dst = &AY; - - *r_dst = MASK_OUT_ABOVE_32(*r_dst - ((((REG_IR >> 9) - 1) & 7) + 1)); -} - - -static void m68k_op_subq_32_ai(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_AI_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subq_32_pi(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PI_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subq_32_pd(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_PD_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subq_32_di(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_DI_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subq_32_ix(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AY_IX_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subq_32_aw(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AW_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subq_32_al(void) -{ - uint src = (((REG_IR >> 9) - 1) & 7) + 1; - uint ea = EA_AL_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src; - - FLAG_N = NFLAG_32(res); - FLAG_Z = MASK_OUT_ABOVE_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - m68ki_write_32(ea, FLAG_Z); -} - - -static void m68k_op_subx_8_rr(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_8(DY); - uint dst = MASK_OUT_ABOVE_8(*r_dst); - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; -} - - -static void m68k_op_subx_16_rr(void) -{ - uint* r_dst = &DX; - uint src = MASK_OUT_ABOVE_16(DY); - uint dst = MASK_OUT_ABOVE_16(*r_dst); - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; -} - - -static void m68k_op_subx_32_rr(void) -{ - uint* r_dst = &DX; - uint src = DY; - uint dst = *r_dst; - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - *r_dst = res; -} - - -static void m68k_op_subx_8_mm_ax7(void) -{ - uint src = OPER_AY_PD_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_subx_8_mm_ay7(void) -{ - uint src = OPER_A7_PD_8(); - uint ea = EA_AX_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_subx_8_mm_axy7(void) -{ - uint src = OPER_A7_PD_8(); - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_subx_8_mm(void) -{ - uint src = OPER_AY_PD_8(); - uint ea = EA_AX_PD_8(); - uint dst = m68ki_read_8(ea); - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_8(res); - FLAG_X = FLAG_C = CFLAG_8(res); - FLAG_V = VFLAG_SUB_8(src, dst, res); - - res = MASK_OUT_ABOVE_8(res); - FLAG_Z |= res; - - m68ki_write_8(ea, res); -} - - -static void m68k_op_subx_16_mm(void) -{ - uint src = OPER_AY_PD_16(); - uint ea = EA_AX_PD_16(); - uint dst = m68ki_read_16(ea); - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_16(res); - FLAG_X = FLAG_C = CFLAG_16(res); - FLAG_V = VFLAG_SUB_16(src, dst, res); - - res = MASK_OUT_ABOVE_16(res); - FLAG_Z |= res; - - m68ki_write_16(ea, res); -} - - -static void m68k_op_subx_32_mm(void) -{ - uint src = OPER_AY_PD_32(); - uint ea = EA_AX_PD_32(); - uint dst = m68ki_read_32(ea); - uint res = dst - src - XFLAG_AS_1(); - - FLAG_N = NFLAG_32(res); - FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); - FLAG_V = VFLAG_SUB_32(src, dst, res); - - res = MASK_OUT_ABOVE_32(res); - FLAG_Z |= res; - - m68ki_write_32(ea, res); -} - - -static void m68k_op_swap_32(void) -{ - uint* r_dst = &DY; - - FLAG_Z = MASK_OUT_ABOVE_32(*r_dst<<16); - *r_dst = (*r_dst>>16) | FLAG_Z; - - FLAG_Z = *r_dst; - FLAG_N = NFLAG_32(*r_dst); - FLAG_C = CFLAG_CLEAR; - FLAG_V = VFLAG_CLEAR; -} - - -static void m68k_op_tas_8_d(void) -{ - uint* r_dst = &DY; - - FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); - FLAG_N = NFLAG_8(*r_dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - *r_dst |= 0x80; -} - - -static void m68k_op_tas_8_ai(void) -{ - uint ea = EA_AY_AI_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_tas_8_pi(void) -{ - uint ea = EA_AY_PI_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_tas_8_pi7(void) -{ - uint ea = EA_A7_PI_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_tas_8_pd(void) -{ - uint ea = EA_AY_PD_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_tas_8_pd7(void) -{ - uint ea = EA_A7_PD_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_tas_8_di(void) -{ - uint ea = EA_AY_DI_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_tas_8_ix(void) -{ - uint ea = EA_AY_IX_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_tas_8_aw(void) -{ - uint ea = EA_AW_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_tas_8_al(void) -{ - uint ea = EA_AL_8(); - uint dst = m68ki_read_8(ea); - uint allow_writeback; - - FLAG_Z = dst; - FLAG_N = NFLAG_8(dst); - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - - /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback - disabled in order to function properly. Some Amiga software may also rely - on this, but only when accessing specific addresses so additional functionality - will be needed. */ - allow_writeback = m68ki_tas_callback(); - - if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); -} - - -static void m68k_op_trap(void) -{ - /* Trap#n stacks exception frame type 0 */ - m68ki_exception_trapN(EXCEPTION_TRAP_BASE + (REG_IR & 0xf)); /* HJB 990403 */ -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_trapt(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapt_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapt_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapf(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapf_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapf_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traphi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_HI()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapls(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LS()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapcc(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_CC()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapcs(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_CS()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapne(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_NE()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapeq(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_EQ()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapvc(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_VC()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapvs(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_VS()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trappl(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_PL()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapmi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_MI()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapge(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_GE()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traplt(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LT()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapgt(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_GT()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traple(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LE()) - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traphi_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_HI()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapls_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LS()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapcc_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_CC()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapcs_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_CS()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapne_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_NE()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapeq_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_EQ()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapvc_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_VC()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapvs_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_VS()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trappl_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_PL()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapmi_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_MI()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapge_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_GE()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traplt_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LT()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapgt_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_GT()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traple_16(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LE()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 2; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traphi_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_HI()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapls_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LS()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapcc_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_CC()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapcs_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_CS()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapne_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_NE()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapeq_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_EQ()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapvc_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_VC()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapvs_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_VS()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trappl_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_PL()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapmi_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_MI()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapge_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_GE()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traplt_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LT()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_trapgt_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_GT()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_traple_32(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - if(COND_LE()) - { - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ - return; - } - REG_PC += 4; - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_trapv(void) -{ - if(COND_VC()) - { - return; - } - m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ -} - - -static void m68k_op_tst_8_d(void) -{ - uint res = MASK_OUT_ABOVE_8(DY); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_ai(void) -{ - uint res = OPER_AY_AI_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_pi(void) -{ - uint res = OPER_AY_PI_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_pi7(void) -{ - uint res = OPER_A7_PI_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_pd(void) -{ - uint res = OPER_AY_PD_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_pd7(void) -{ - uint res = OPER_A7_PD_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_di(void) -{ - uint res = OPER_AY_DI_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_ix(void) -{ - uint res = OPER_AY_IX_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_aw(void) -{ - uint res = OPER_AW_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_8_al(void) -{ - uint res = OPER_AL_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_tst_8_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_PCDI_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_tst_8_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_PCIX_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_tst_8_i(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_I_8(); - - FLAG_N = NFLAG_8(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_tst_16_d(void) -{ - uint res = MASK_OUT_ABOVE_16(DY); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_tst_16_a(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = MAKE_INT_16(AY); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_tst_16_ai(void) -{ - uint res = OPER_AY_AI_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_16_pi(void) -{ - uint res = OPER_AY_PI_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_16_pd(void) -{ - uint res = OPER_AY_PD_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_16_di(void) -{ - uint res = OPER_AY_DI_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_16_ix(void) -{ - uint res = OPER_AY_IX_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_16_aw(void) -{ - uint res = OPER_AW_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_16_al(void) -{ - uint res = OPER_AL_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_tst_16_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_PCDI_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_tst_16_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_PCIX_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_tst_16_i(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_I_16(); - - FLAG_N = NFLAG_16(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_tst_32_d(void) -{ - uint res = DY; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_tst_32_a(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = AY; - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_tst_32_ai(void) -{ - uint res = OPER_AY_AI_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_32_pi(void) -{ - uint res = OPER_AY_PI_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_32_pd(void) -{ - uint res = OPER_AY_PD_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_32_di(void) -{ - uint res = OPER_AY_DI_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_32_ix(void) -{ - uint res = OPER_AY_IX_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_32_aw(void) -{ - uint res = OPER_AW_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -static void m68k_op_tst_32_al(void) -{ - uint res = OPER_AL_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_tst_32_pcdi(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_PCDI_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_tst_32_pcix(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_PCIX_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_tst_32_i(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint res = OPER_I_32(); - - FLAG_N = NFLAG_32(res); - FLAG_Z = res; - FLAG_V = VFLAG_CLEAR; - FLAG_C = CFLAG_CLEAR; - return; - } - m68ki_exception_illegal(); -} -#endif - - -static void m68k_op_unlk_32_a7(void) -{ - REG_A[7] = m68ki_read_32(REG_A[7]); -} - - -static void m68k_op_unlk_32(void) -{ - uint* r_dst = &AY; - - REG_A[7] = *r_dst; - *r_dst = m68ki_pull_32(); -} - - -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -static void m68k_op_unpk_16_rr(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Note: DX and DY are reversed in Motorola's docs */ - uint src = DY; - uint* r_dst = &DX; - - *r_dst = MASK_OUT_BELOW_16(*r_dst) | (((((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16()) & 0xffff); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_unpk_16_mm_ax7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Note: AX and AY are reversed in Motorola's docs */ - uint src = OPER_AY_PD_8(); - uint ea_dst; - - src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16(); - ea_dst = EA_A7_PD_8(); - m68ki_write_8(ea_dst, (src >> 8) & 0xff); - ea_dst = EA_A7_PD_8(); - m68ki_write_8(ea_dst, src & 0xff); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_unpk_16_mm_ay7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Note: AX and AY are reversed in Motorola's docs */ - uint src = OPER_A7_PD_8(); - uint ea_dst; - - src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16(); - ea_dst = EA_AX_PD_8(); - m68ki_write_8(ea_dst, (src >> 8) & 0xff); - ea_dst = EA_AX_PD_8(); - m68ki_write_8(ea_dst, src & 0xff); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_unpk_16_mm_axy7(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - uint src = OPER_A7_PD_8(); - uint ea_dst; - - src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16(); - ea_dst = EA_A7_PD_8(); - m68ki_write_8(ea_dst, (src >> 8) & 0xff); - ea_dst = EA_A7_PD_8(); - m68ki_write_8(ea_dst, src & 0xff); - return; - } - m68ki_exception_illegal(); -} - - -static void m68k_op_unpk_16_mm(void) -{ - if(CPU_TYPE_IS_EC020_PLUS(CPU_TYPE)) - { - /* Note: AX and AY are reversed in Motorola's docs */ - uint src = OPER_AY_PD_8(); - uint ea_dst; - - src = (((src << 4) & 0x0f00) | (src & 0x000f)) + OPER_I_16(); - ea_dst = EA_AX_PD_8(); - m68ki_write_8(ea_dst, (src >> 8) & 0xff); - ea_dst = EA_AX_PD_8(); - m68ki_write_8(ea_dst, src & 0xff); - return; - } - m68ki_exception_illegal(); -} -#endif - - -/* ======================================================================== */ -/* ============================== END OF FILE ============================= */ -/* ======================================================================== */ - - -/* ======================================================================== */ -/* ========================= OPCODE TABLE BUILDER ========================= */ -/* ======================================================================== */ - -#include "m68kops.h" - -void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */ -unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */ - -/* This is used to generate the opcode handler jump table */ -typedef struct -{ - void (*opcode_handler)(void); /* handler function */ - unsigned int mask; /* mask on opcode */ - unsigned int match; /* what to match after masking */ - unsigned char cycles[4]; /* cycles each cpu type takes */ -} opcode_handler_struct; - - -/* Opcode handler table */ -static const opcode_handler_struct m68k_opcode_handler_table[] = -{ -/* function mask match 000 010 020 040 */ - - - {m68k_op_1010 , 0xf000, 0xa000, { 4, 4, 4, 4}}, - {m68k_op_1111 , 0xf000, 0xf000, { 4, 4, 4, 4}}, - {m68k_op_moveq_32 , 0xf100, 0x7000, { 4, 4, 2, 2}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cpbcc_32 , 0xf180, 0xf080, { 0, 0, 4, 0}}, - {m68k_op_cpgen_32 , 0xf1c0, 0xf000, { 0, 0, 4, 0}}, - {m68k_op_cpscc_32 , 0xf1c0, 0xf040, { 0, 0, 4, 0}}, -#endif - {m68k_op_bra_8 , 0xff00, 0x6000, { 10, 10, 10, 10}}, - {m68k_op_bsr_8 , 0xff00, 0x6100, { 18, 18, 7, 7}}, - {m68k_op_bhi_8 , 0xff00, 0x6200, { 10, 10, 6, 6}}, - {m68k_op_bls_8 , 0xff00, 0x6300, { 10, 10, 6, 6}}, - {m68k_op_bcc_8 , 0xff00, 0x6400, { 10, 10, 6, 6}}, - {m68k_op_bcs_8 , 0xff00, 0x6500, { 10, 10, 6, 6}}, - {m68k_op_bne_8 , 0xff00, 0x6600, { 10, 10, 6, 6}}, - {m68k_op_beq_8 , 0xff00, 0x6700, { 10, 10, 6, 6}}, - {m68k_op_bvc_8 , 0xff00, 0x6800, { 10, 10, 6, 6}}, - {m68k_op_bvs_8 , 0xff00, 0x6900, { 10, 10, 6, 6}}, - {m68k_op_bpl_8 , 0xff00, 0x6a00, { 10, 10, 6, 6}}, - {m68k_op_bmi_8 , 0xff00, 0x6b00, { 10, 10, 6, 6}}, - {m68k_op_bge_8 , 0xff00, 0x6c00, { 10, 10, 6, 6}}, - {m68k_op_blt_8 , 0xff00, 0x6d00, { 10, 10, 6, 6}}, - {m68k_op_bgt_8 , 0xff00, 0x6e00, { 10, 10, 6, 6}}, - {m68k_op_ble_8 , 0xff00, 0x6f00, { 10, 10, 6, 6}}, -#if M68K_EMULATE_040 - {m68k_op_040fpu0_32 , 0xff00, 0xf200, { 0, 0, 0, 0}}, - {m68k_op_040fpu1_32 , 0xff00, 0xf300, { 0, 0, 0, 0}}, -#endif - {m68k_op_btst_32_r_d , 0xf1f8, 0x0100, { 6, 6, 4, 4}}, - {m68k_op_movep_16_er , 0xf1f8, 0x0108, { 16, 16, 12, 12}}, - {m68k_op_btst_8_r_ai , 0xf1f8, 0x0110, { 8, 8, 8, 8}}, - {m68k_op_btst_8_r_pi , 0xf1f8, 0x0118, { 8, 8, 8, 8}}, - {m68k_op_btst_8_r_pd , 0xf1f8, 0x0120, { 10, 10, 9, 9}}, - {m68k_op_btst_8_r_di , 0xf1f8, 0x0128, { 12, 12, 9, 9}}, - {m68k_op_btst_8_r_ix , 0xf1f8, 0x0130, { 14, 14, 11, 11}}, - {m68k_op_bchg_32_r_d , 0xf1f8, 0x0140, { 8, 8, 4, 4}}, - {m68k_op_movep_32_er , 0xf1f8, 0x0148, { 24, 24, 18, 18}}, - {m68k_op_bchg_8_r_ai , 0xf1f8, 0x0150, { 12, 12, 8, 8}}, - {m68k_op_bchg_8_r_pi , 0xf1f8, 0x0158, { 12, 12, 8, 8}}, - {m68k_op_bchg_8_r_pd , 0xf1f8, 0x0160, { 14, 14, 9, 9}}, - {m68k_op_bchg_8_r_di , 0xf1f8, 0x0168, { 16, 16, 9, 9}}, - {m68k_op_bchg_8_r_ix , 0xf1f8, 0x0170, { 18, 18, 11, 11}}, - {m68k_op_bclr_32_r_d , 0xf1f8, 0x0180, { 10, 10, 4, 4}}, - {m68k_op_movep_16_re , 0xf1f8, 0x0188, { 16, 16, 11, 11}}, - {m68k_op_bclr_8_r_ai , 0xf1f8, 0x0190, { 12, 14, 8, 8}}, - {m68k_op_bclr_8_r_pi , 0xf1f8, 0x0198, { 12, 14, 8, 8}}, - {m68k_op_bclr_8_r_pd , 0xf1f8, 0x01a0, { 14, 16, 9, 9}}, - {m68k_op_bclr_8_r_di , 0xf1f8, 0x01a8, { 16, 18, 9, 9}}, - {m68k_op_bclr_8_r_ix , 0xf1f8, 0x01b0, { 18, 20, 11, 11}}, - {m68k_op_bset_32_r_d , 0xf1f8, 0x01c0, { 8, 8, 4, 4}}, - {m68k_op_movep_32_re , 0xf1f8, 0x01c8, { 24, 24, 17, 17}}, - {m68k_op_bset_8_r_ai , 0xf1f8, 0x01d0, { 12, 12, 8, 8}}, - {m68k_op_bset_8_r_pi , 0xf1f8, 0x01d8, { 12, 12, 8, 8}}, - {m68k_op_bset_8_r_pd , 0xf1f8, 0x01e0, { 14, 14, 9, 9}}, - {m68k_op_bset_8_r_di , 0xf1f8, 0x01e8, { 16, 16, 9, 9}}, - {m68k_op_bset_8_r_ix , 0xf1f8, 0x01f0, { 18, 18, 11, 11}}, - {m68k_op_move_8_d_d , 0xf1f8, 0x1000, { 4, 4, 2, 2}}, - {m68k_op_move_8_d_ai , 0xf1f8, 0x1010, { 8, 8, 6, 6}}, - {m68k_op_move_8_d_pi , 0xf1f8, 0x1018, { 8, 8, 6, 6}}, - {m68k_op_move_8_d_pd , 0xf1f8, 0x1020, { 10, 10, 7, 7}}, - {m68k_op_move_8_d_di , 0xf1f8, 0x1028, { 12, 12, 7, 7}}, - {m68k_op_move_8_d_ix , 0xf1f8, 0x1030, { 14, 14, 9, 9}}, - {m68k_op_move_8_ai_d , 0xf1f8, 0x1080, { 8, 8, 4, 4}}, - {m68k_op_move_8_ai_ai , 0xf1f8, 0x1090, { 12, 12, 8, 8}}, - {m68k_op_move_8_ai_pi , 0xf1f8, 0x1098, { 12, 12, 8, 8}}, - {m68k_op_move_8_ai_pd , 0xf1f8, 0x10a0, { 14, 14, 9, 9}}, - {m68k_op_move_8_ai_di , 0xf1f8, 0x10a8, { 16, 16, 9, 9}}, - {m68k_op_move_8_ai_ix , 0xf1f8, 0x10b0, { 18, 18, 11, 11}}, - {m68k_op_move_8_pi_d , 0xf1f8, 0x10c0, { 8, 8, 4, 4}}, - {m68k_op_move_8_pi_ai , 0xf1f8, 0x10d0, { 12, 12, 8, 8}}, - {m68k_op_move_8_pi_pi , 0xf1f8, 0x10d8, { 12, 12, 8, 8}}, - {m68k_op_move_8_pi_pd , 0xf1f8, 0x10e0, { 14, 14, 9, 9}}, - {m68k_op_move_8_pi_di , 0xf1f8, 0x10e8, { 16, 16, 9, 9}}, - {m68k_op_move_8_pi_ix , 0xf1f8, 0x10f0, { 18, 18, 11, 11}}, - {m68k_op_move_8_pd_d , 0xf1f8, 0x1100, { 8, 8, 5, 5}}, - {m68k_op_move_8_pd_ai , 0xf1f8, 0x1110, { 12, 12, 9, 9}}, - {m68k_op_move_8_pd_pi , 0xf1f8, 0x1118, { 12, 12, 9, 9}}, - {m68k_op_move_8_pd_pd , 0xf1f8, 0x1120, { 14, 14, 10, 10}}, - {m68k_op_move_8_pd_di , 0xf1f8, 0x1128, { 16, 16, 10, 10}}, - {m68k_op_move_8_pd_ix , 0xf1f8, 0x1130, { 18, 18, 12, 12}}, - {m68k_op_move_8_di_d , 0xf1f8, 0x1140, { 12, 12, 5, 5}}, - {m68k_op_move_8_di_ai , 0xf1f8, 0x1150, { 16, 16, 9, 9}}, - {m68k_op_move_8_di_pi , 0xf1f8, 0x1158, { 16, 16, 9, 9}}, - {m68k_op_move_8_di_pd , 0xf1f8, 0x1160, { 18, 18, 10, 10}}, - {m68k_op_move_8_di_di , 0xf1f8, 0x1168, { 20, 20, 10, 10}}, - {m68k_op_move_8_di_ix , 0xf1f8, 0x1170, { 22, 22, 12, 12}}, - {m68k_op_move_8_ix_d , 0xf1f8, 0x1180, { 14, 14, 7, 7}}, - {m68k_op_move_8_ix_ai , 0xf1f8, 0x1190, { 18, 18, 11, 11}}, - {m68k_op_move_8_ix_pi , 0xf1f8, 0x1198, { 18, 18, 11, 11}}, - {m68k_op_move_8_ix_pd , 0xf1f8, 0x11a0, { 20, 20, 12, 12}}, - {m68k_op_move_8_ix_di , 0xf1f8, 0x11a8, { 22, 22, 12, 12}}, - {m68k_op_move_8_ix_ix , 0xf1f8, 0x11b0, { 24, 24, 14, 14}}, - {m68k_op_move_32_d_d , 0xf1f8, 0x2000, { 4, 4, 2, 2}}, - {m68k_op_move_32_d_a , 0xf1f8, 0x2008, { 4, 4, 2, 2}}, - {m68k_op_move_32_d_ai , 0xf1f8, 0x2010, { 12, 12, 6, 6}}, - {m68k_op_move_32_d_pi , 0xf1f8, 0x2018, { 12, 12, 6, 6}}, - {m68k_op_move_32_d_pd , 0xf1f8, 0x2020, { 14, 14, 7, 7}}, - {m68k_op_move_32_d_di , 0xf1f8, 0x2028, { 16, 16, 7, 7}}, - {m68k_op_move_32_d_ix , 0xf1f8, 0x2030, { 18, 18, 9, 9}}, - {m68k_op_movea_32_d , 0xf1f8, 0x2040, { 4, 4, 2, 2}}, - {m68k_op_movea_32_a , 0xf1f8, 0x2048, { 4, 4, 2, 2}}, - {m68k_op_movea_32_ai , 0xf1f8, 0x2050, { 12, 12, 6, 6}}, - {m68k_op_movea_32_pi , 0xf1f8, 0x2058, { 12, 12, 6, 6}}, - {m68k_op_movea_32_pd , 0xf1f8, 0x2060, { 14, 14, 7, 7}}, - {m68k_op_movea_32_di , 0xf1f8, 0x2068, { 16, 16, 7, 7}}, - {m68k_op_movea_32_ix , 0xf1f8, 0x2070, { 18, 18, 9, 9}}, - {m68k_op_move_32_ai_d , 0xf1f8, 0x2080, { 12, 12, 4, 4}}, - {m68k_op_move_32_ai_a , 0xf1f8, 0x2088, { 12, 12, 4, 4}}, - {m68k_op_move_32_ai_ai , 0xf1f8, 0x2090, { 20, 20, 8, 8}}, - {m68k_op_move_32_ai_pi , 0xf1f8, 0x2098, { 20, 20, 8, 8}}, - {m68k_op_move_32_ai_pd , 0xf1f8, 0x20a0, { 22, 22, 9, 9}}, - {m68k_op_move_32_ai_di , 0xf1f8, 0x20a8, { 24, 24, 9, 9}}, - {m68k_op_move_32_ai_ix , 0xf1f8, 0x20b0, { 26, 26, 11, 11}}, - {m68k_op_move_32_pi_d , 0xf1f8, 0x20c0, { 12, 12, 4, 4}}, - {m68k_op_move_32_pi_a , 0xf1f8, 0x20c8, { 12, 12, 4, 4}}, - {m68k_op_move_32_pi_ai , 0xf1f8, 0x20d0, { 20, 20, 8, 8}}, - {m68k_op_move_32_pi_pi , 0xf1f8, 0x20d8, { 20, 20, 8, 8}}, - {m68k_op_move_32_pi_pd , 0xf1f8, 0x20e0, { 22, 22, 9, 9}}, - {m68k_op_move_32_pi_di , 0xf1f8, 0x20e8, { 24, 24, 9, 9}}, - {m68k_op_move_32_pi_ix , 0xf1f8, 0x20f0, { 26, 26, 11, 11}}, - {m68k_op_move_32_pd_d , 0xf1f8, 0x2100, { 12, 14, 5, 5}}, - {m68k_op_move_32_pd_a , 0xf1f8, 0x2108, { 12, 14, 5, 5}}, - {m68k_op_move_32_pd_ai , 0xf1f8, 0x2110, { 20, 22, 9, 9}}, - {m68k_op_move_32_pd_pi , 0xf1f8, 0x2118, { 20, 22, 9, 9}}, - {m68k_op_move_32_pd_pd , 0xf1f8, 0x2120, { 22, 24, 10, 10}}, - {m68k_op_move_32_pd_di , 0xf1f8, 0x2128, { 24, 26, 10, 10}}, - {m68k_op_move_32_pd_ix , 0xf1f8, 0x2130, { 26, 28, 12, 12}}, - {m68k_op_move_32_di_d , 0xf1f8, 0x2140, { 16, 16, 5, 5}}, - {m68k_op_move_32_di_a , 0xf1f8, 0x2148, { 16, 16, 5, 5}}, - {m68k_op_move_32_di_ai , 0xf1f8, 0x2150, { 24, 24, 9, 9}}, - {m68k_op_move_32_di_pi , 0xf1f8, 0x2158, { 24, 24, 9, 9}}, - {m68k_op_move_32_di_pd , 0xf1f8, 0x2160, { 26, 26, 10, 10}}, - {m68k_op_move_32_di_di , 0xf1f8, 0x2168, { 28, 28, 10, 10}}, - {m68k_op_move_32_di_ix , 0xf1f8, 0x2170, { 30, 30, 12, 12}}, - {m68k_op_move_32_ix_d , 0xf1f8, 0x2180, { 18, 18, 7, 7}}, - {m68k_op_move_32_ix_a , 0xf1f8, 0x2188, { 18, 18, 7, 7}}, - {m68k_op_move_32_ix_ai , 0xf1f8, 0x2190, { 26, 26, 11, 11}}, - {m68k_op_move_32_ix_pi , 0xf1f8, 0x2198, { 26, 26, 11, 11}}, - {m68k_op_move_32_ix_pd , 0xf1f8, 0x21a0, { 28, 28, 12, 12}}, - {m68k_op_move_32_ix_di , 0xf1f8, 0x21a8, { 30, 30, 12, 12}}, - {m68k_op_move_32_ix_ix , 0xf1f8, 0x21b0, { 32, 32, 14, 14}}, - {m68k_op_move_16_d_d , 0xf1f8, 0x3000, { 4, 4, 2, 2}}, - {m68k_op_move_16_d_a , 0xf1f8, 0x3008, { 4, 4, 2, 2}}, - {m68k_op_move_16_d_ai , 0xf1f8, 0x3010, { 8, 8, 6, 6}}, - {m68k_op_move_16_d_pi , 0xf1f8, 0x3018, { 8, 8, 6, 6}}, - {m68k_op_move_16_d_pd , 0xf1f8, 0x3020, { 10, 10, 7, 7}}, - {m68k_op_move_16_d_di , 0xf1f8, 0x3028, { 12, 12, 7, 7}}, - {m68k_op_move_16_d_ix , 0xf1f8, 0x3030, { 14, 14, 9, 9}}, - {m68k_op_movea_16_d , 0xf1f8, 0x3040, { 4, 4, 2, 2}}, - {m68k_op_movea_16_a , 0xf1f8, 0x3048, { 4, 4, 2, 2}}, - {m68k_op_movea_16_ai , 0xf1f8, 0x3050, { 8, 8, 6, 6}}, - {m68k_op_movea_16_pi , 0xf1f8, 0x3058, { 8, 8, 6, 6}}, - {m68k_op_movea_16_pd , 0xf1f8, 0x3060, { 10, 10, 7, 7}}, - {m68k_op_movea_16_di , 0xf1f8, 0x3068, { 12, 12, 7, 7}}, - {m68k_op_movea_16_ix , 0xf1f8, 0x3070, { 14, 14, 9, 9}}, - {m68k_op_move_16_ai_d , 0xf1f8, 0x3080, { 8, 8, 4, 4}}, - {m68k_op_move_16_ai_a , 0xf1f8, 0x3088, { 8, 8, 4, 4}}, - {m68k_op_move_16_ai_ai , 0xf1f8, 0x3090, { 12, 12, 8, 8}}, - {m68k_op_move_16_ai_pi , 0xf1f8, 0x3098, { 12, 12, 8, 8}}, - {m68k_op_move_16_ai_pd , 0xf1f8, 0x30a0, { 14, 14, 9, 9}}, - {m68k_op_move_16_ai_di , 0xf1f8, 0x30a8, { 16, 16, 9, 9}}, - {m68k_op_move_16_ai_ix , 0xf1f8, 0x30b0, { 18, 18, 11, 11}}, - {m68k_op_move_16_pi_d , 0xf1f8, 0x30c0, { 8, 8, 4, 4}}, - {m68k_op_move_16_pi_a , 0xf1f8, 0x30c8, { 8, 8, 4, 4}}, - {m68k_op_move_16_pi_ai , 0xf1f8, 0x30d0, { 12, 12, 8, 8}}, - {m68k_op_move_16_pi_pi , 0xf1f8, 0x30d8, { 12, 12, 8, 8}}, - {m68k_op_move_16_pi_pd , 0xf1f8, 0x30e0, { 14, 14, 9, 9}}, - {m68k_op_move_16_pi_di , 0xf1f8, 0x30e8, { 16, 16, 9, 9}}, - {m68k_op_move_16_pi_ix , 0xf1f8, 0x30f0, { 18, 18, 11, 11}}, - {m68k_op_move_16_pd_d , 0xf1f8, 0x3100, { 8, 8, 5, 5}}, - {m68k_op_move_16_pd_a , 0xf1f8, 0x3108, { 8, 8, 5, 5}}, - {m68k_op_move_16_pd_ai , 0xf1f8, 0x3110, { 12, 12, 9, 9}}, - {m68k_op_move_16_pd_pi , 0xf1f8, 0x3118, { 12, 12, 9, 9}}, - {m68k_op_move_16_pd_pd , 0xf1f8, 0x3120, { 14, 14, 10, 10}}, - {m68k_op_move_16_pd_di , 0xf1f8, 0x3128, { 16, 16, 10, 10}}, - {m68k_op_move_16_pd_ix , 0xf1f8, 0x3130, { 18, 18, 12, 12}}, - {m68k_op_move_16_di_d , 0xf1f8, 0x3140, { 12, 12, 5, 5}}, - {m68k_op_move_16_di_a , 0xf1f8, 0x3148, { 12, 12, 5, 5}}, - {m68k_op_move_16_di_ai , 0xf1f8, 0x3150, { 16, 16, 9, 9}}, - {m68k_op_move_16_di_pi , 0xf1f8, 0x3158, { 16, 16, 9, 9}}, - {m68k_op_move_16_di_pd , 0xf1f8, 0x3160, { 18, 18, 10, 10}}, - {m68k_op_move_16_di_di , 0xf1f8, 0x3168, { 20, 20, 10, 10}}, - {m68k_op_move_16_di_ix , 0xf1f8, 0x3170, { 22, 22, 12, 12}}, - {m68k_op_move_16_ix_d , 0xf1f8, 0x3180, { 14, 14, 7, 7}}, - {m68k_op_move_16_ix_a , 0xf1f8, 0x3188, { 14, 14, 7, 7}}, - {m68k_op_move_16_ix_ai , 0xf1f8, 0x3190, { 18, 18, 11, 11}}, - {m68k_op_move_16_ix_pi , 0xf1f8, 0x3198, { 18, 18, 11, 11}}, - {m68k_op_move_16_ix_pd , 0xf1f8, 0x31a0, { 20, 20, 12, 12}}, - {m68k_op_move_16_ix_di , 0xf1f8, 0x31a8, { 22, 22, 12, 12}}, - {m68k_op_move_16_ix_ix , 0xf1f8, 0x31b0, { 24, 24, 14, 14}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_chk_32_d , 0xf1f8, 0x4100, { 0, 0, 8, 8}}, - {m68k_op_chk_32_ai , 0xf1f8, 0x4110, { 0, 0, 12, 12}}, - {m68k_op_chk_32_pi , 0xf1f8, 0x4118, { 0, 0, 12, 12}}, - {m68k_op_chk_32_pd , 0xf1f8, 0x4120, { 0, 0, 13, 13}}, - {m68k_op_chk_32_di , 0xf1f8, 0x4128, { 0, 0, 13, 13}}, - {m68k_op_chk_32_ix , 0xf1f8, 0x4130, { 0, 0, 15, 15}}, -#endif - {m68k_op_chk_16_d , 0xf1f8, 0x4180, { 10, 8, 8, 8}}, - {m68k_op_chk_16_ai , 0xf1f8, 0x4190, { 14, 12, 12, 12}}, - {m68k_op_chk_16_pi , 0xf1f8, 0x4198, { 14, 12, 12, 12}}, - {m68k_op_chk_16_pd , 0xf1f8, 0x41a0, { 16, 14, 13, 13}}, - {m68k_op_chk_16_di , 0xf1f8, 0x41a8, { 18, 16, 13, 13}}, - {m68k_op_chk_16_ix , 0xf1f8, 0x41b0, { 20, 18, 15, 15}}, - {m68k_op_lea_32_ai , 0xf1f8, 0x41d0, { 4, 4, 6, 6}}, - {m68k_op_lea_32_di , 0xf1f8, 0x41e8, { 8, 8, 7, 7}}, - {m68k_op_lea_32_ix , 0xf1f8, 0x41f0, { 12, 12, 9, 9}}, - {m68k_op_addq_8_d , 0xf1f8, 0x5000, { 4, 4, 2, 2}}, - {m68k_op_addq_8_ai , 0xf1f8, 0x5010, { 12, 12, 8, 8}}, - {m68k_op_addq_8_pi , 0xf1f8, 0x5018, { 12, 12, 8, 8}}, - {m68k_op_addq_8_pd , 0xf1f8, 0x5020, { 14, 14, 9, 9}}, - {m68k_op_addq_8_di , 0xf1f8, 0x5028, { 16, 16, 9, 9}}, - {m68k_op_addq_8_ix , 0xf1f8, 0x5030, { 18, 18, 11, 11}}, - {m68k_op_addq_16_d , 0xf1f8, 0x5040, { 4, 4, 2, 2}}, - {m68k_op_addq_16_a , 0xf1f8, 0x5048, { 4, 4, 2, 2}}, - {m68k_op_addq_16_ai , 0xf1f8, 0x5050, { 12, 12, 8, 8}}, - {m68k_op_addq_16_pi , 0xf1f8, 0x5058, { 12, 12, 8, 8}}, - {m68k_op_addq_16_pd , 0xf1f8, 0x5060, { 14, 14, 9, 9}}, - {m68k_op_addq_16_di , 0xf1f8, 0x5068, { 16, 16, 9, 9}}, - {m68k_op_addq_16_ix , 0xf1f8, 0x5070, { 18, 18, 11, 11}}, - {m68k_op_addq_32_d , 0xf1f8, 0x5080, { 8, 8, 2, 2}}, - {m68k_op_addq_32_a , 0xf1f8, 0x5088, { 8, 8, 2, 2}}, - {m68k_op_addq_32_ai , 0xf1f8, 0x5090, { 20, 20, 8, 8}}, - {m68k_op_addq_32_pi , 0xf1f8, 0x5098, { 20, 20, 8, 8}}, - {m68k_op_addq_32_pd , 0xf1f8, 0x50a0, { 22, 22, 9, 9}}, - {m68k_op_addq_32_di , 0xf1f8, 0x50a8, { 24, 24, 9, 9}}, - {m68k_op_addq_32_ix , 0xf1f8, 0x50b0, { 26, 26, 11, 11}}, - {m68k_op_subq_8_d , 0xf1f8, 0x5100, { 4, 4, 2, 2}}, - {m68k_op_subq_8_ai , 0xf1f8, 0x5110, { 12, 12, 8, 8}}, - {m68k_op_subq_8_pi , 0xf1f8, 0x5118, { 12, 12, 8, 8}}, - {m68k_op_subq_8_pd , 0xf1f8, 0x5120, { 14, 14, 9, 9}}, - {m68k_op_subq_8_di , 0xf1f8, 0x5128, { 16, 16, 9, 9}}, - {m68k_op_subq_8_ix , 0xf1f8, 0x5130, { 18, 18, 11, 11}}, - {m68k_op_subq_16_d , 0xf1f8, 0x5140, { 4, 4, 2, 2}}, - {m68k_op_subq_16_a , 0xf1f8, 0x5148, { 8, 4, 2, 2}}, - {m68k_op_subq_16_ai , 0xf1f8, 0x5150, { 12, 12, 8, 8}}, - {m68k_op_subq_16_pi , 0xf1f8, 0x5158, { 12, 12, 8, 8}}, - {m68k_op_subq_16_pd , 0xf1f8, 0x5160, { 14, 14, 9, 9}}, - {m68k_op_subq_16_di , 0xf1f8, 0x5168, { 16, 16, 9, 9}}, - {m68k_op_subq_16_ix , 0xf1f8, 0x5170, { 18, 18, 11, 11}}, - {m68k_op_subq_32_d , 0xf1f8, 0x5180, { 8, 8, 2, 2}}, - {m68k_op_subq_32_a , 0xf1f8, 0x5188, { 8, 8, 2, 2}}, - {m68k_op_subq_32_ai , 0xf1f8, 0x5190, { 20, 20, 8, 8}}, - {m68k_op_subq_32_pi , 0xf1f8, 0x5198, { 20, 20, 8, 8}}, - {m68k_op_subq_32_pd , 0xf1f8, 0x51a0, { 22, 22, 9, 9}}, - {m68k_op_subq_32_di , 0xf1f8, 0x51a8, { 24, 24, 9, 9}}, - {m68k_op_subq_32_ix , 0xf1f8, 0x51b0, { 26, 26, 11, 11}}, - {m68k_op_or_8_er_d , 0xf1f8, 0x8000, { 4, 4, 2, 2}}, - {m68k_op_or_8_er_ai , 0xf1f8, 0x8010, { 8, 8, 6, 6}}, - {m68k_op_or_8_er_pi , 0xf1f8, 0x8018, { 8, 8, 6, 6}}, - {m68k_op_or_8_er_pd , 0xf1f8, 0x8020, { 10, 10, 7, 7}}, - {m68k_op_or_8_er_di , 0xf1f8, 0x8028, { 12, 12, 7, 7}}, - {m68k_op_or_8_er_ix , 0xf1f8, 0x8030, { 14, 14, 9, 9}}, - {m68k_op_or_16_er_d , 0xf1f8, 0x8040, { 4, 4, 2, 2}}, - {m68k_op_or_16_er_ai , 0xf1f8, 0x8050, { 8, 8, 6, 6}}, - {m68k_op_or_16_er_pi , 0xf1f8, 0x8058, { 8, 8, 6, 6}}, - {m68k_op_or_16_er_pd , 0xf1f8, 0x8060, { 10, 10, 7, 7}}, - {m68k_op_or_16_er_di , 0xf1f8, 0x8068, { 12, 12, 7, 7}}, - {m68k_op_or_16_er_ix , 0xf1f8, 0x8070, { 14, 14, 9, 9}}, - {m68k_op_or_32_er_d , 0xf1f8, 0x8080, { 8, 6, 2, 2}}, - {m68k_op_or_32_er_ai , 0xf1f8, 0x8090, { 14, 14, 6, 6}}, - {m68k_op_or_32_er_pi , 0xf1f8, 0x8098, { 14, 14, 6, 6}}, - {m68k_op_or_32_er_pd , 0xf1f8, 0x80a0, { 16, 16, 7, 7}}, - {m68k_op_or_32_er_di , 0xf1f8, 0x80a8, { 18, 18, 7, 7}}, - {m68k_op_or_32_er_ix , 0xf1f8, 0x80b0, { 20, 20, 9, 9}}, - {m68k_op_divu_16_d , 0xf1f8, 0x80c0, { 0, 108, 44, 44}}, - {m68k_op_divu_16_ai , 0xf1f8, 0x80d0, { 4, 112, 48, 48}}, - {m68k_op_divu_16_pi , 0xf1f8, 0x80d8, { 4, 112, 48, 48}}, - {m68k_op_divu_16_pd , 0xf1f8, 0x80e0, { 6, 114, 49, 49}}, - {m68k_op_divu_16_di , 0xf1f8, 0x80e8, { 8, 116, 49, 49}}, - {m68k_op_divu_16_ix , 0xf1f8, 0x80f0, { 10, 118, 51, 51}}, - {m68k_op_sbcd_8_rr , 0xf1f8, 0x8100, { 6, 6, 4, 4}}, - {m68k_op_sbcd_8_mm , 0xf1f8, 0x8108, { 18, 18, 16, 16}}, - {m68k_op_or_8_re_ai , 0xf1f8, 0x8110, { 12, 12, 8, 8}}, - {m68k_op_or_8_re_pi , 0xf1f8, 0x8118, { 12, 12, 8, 8}}, - {m68k_op_or_8_re_pd , 0xf1f8, 0x8120, { 14, 14, 9, 9}}, - {m68k_op_or_8_re_di , 0xf1f8, 0x8128, { 16, 16, 9, 9}}, - {m68k_op_or_8_re_ix , 0xf1f8, 0x8130, { 18, 18, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_pack_16_rr , 0xf1f8, 0x8140, { 0, 0, 6, 6}}, - {m68k_op_pack_16_mm , 0xf1f8, 0x8148, { 0, 0, 13, 13}}, -#endif - {m68k_op_or_16_re_ai , 0xf1f8, 0x8150, { 12, 12, 8, 8}}, - {m68k_op_or_16_re_pi , 0xf1f8, 0x8158, { 12, 12, 8, 8}}, - {m68k_op_or_16_re_pd , 0xf1f8, 0x8160, { 14, 14, 9, 9}}, - {m68k_op_or_16_re_di , 0xf1f8, 0x8168, { 16, 16, 9, 9}}, - {m68k_op_or_16_re_ix , 0xf1f8, 0x8170, { 18, 18, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_unpk_16_rr , 0xf1f8, 0x8180, { 0, 0, 8, 8}}, - {m68k_op_unpk_16_mm , 0xf1f8, 0x8188, { 0, 0, 13, 13}}, -#endif - {m68k_op_or_32_re_ai , 0xf1f8, 0x8190, { 20, 20, 8, 8}}, - {m68k_op_or_32_re_pi , 0xf1f8, 0x8198, { 20, 20, 8, 8}}, - {m68k_op_or_32_re_pd , 0xf1f8, 0x81a0, { 22, 22, 9, 9}}, - {m68k_op_or_32_re_di , 0xf1f8, 0x81a8, { 24, 24, 9, 9}}, - {m68k_op_or_32_re_ix , 0xf1f8, 0x81b0, { 26, 26, 11, 11}}, - {m68k_op_divs_16_d , 0xf1f8, 0x81c0, { 0, 122, 56, 56}}, - {m68k_op_divs_16_ai , 0xf1f8, 0x81d0, { 4, 126, 60, 60}}, - {m68k_op_divs_16_pi , 0xf1f8, 0x81d8, { 4, 126, 60, 60}}, - {m68k_op_divs_16_pd , 0xf1f8, 0x81e0, { 6, 128, 61, 61}}, - {m68k_op_divs_16_di , 0xf1f8, 0x81e8, { 8, 130, 61, 61}}, - {m68k_op_divs_16_ix , 0xf1f8, 0x81f0, { 10, 132, 63, 63}}, - {m68k_op_sub_8_er_d , 0xf1f8, 0x9000, { 4, 4, 2, 2}}, - {m68k_op_sub_8_er_ai , 0xf1f8, 0x9010, { 8, 8, 6, 6}}, - {m68k_op_sub_8_er_pi , 0xf1f8, 0x9018, { 8, 8, 6, 6}}, - {m68k_op_sub_8_er_pd , 0xf1f8, 0x9020, { 10, 10, 7, 7}}, - {m68k_op_sub_8_er_di , 0xf1f8, 0x9028, { 12, 12, 7, 7}}, - {m68k_op_sub_8_er_ix , 0xf1f8, 0x9030, { 14, 14, 9, 9}}, - {m68k_op_sub_16_er_d , 0xf1f8, 0x9040, { 4, 4, 2, 2}}, - {m68k_op_sub_16_er_a , 0xf1f8, 0x9048, { 4, 4, 2, 2}}, - {m68k_op_sub_16_er_ai , 0xf1f8, 0x9050, { 8, 8, 6, 6}}, - {m68k_op_sub_16_er_pi , 0xf1f8, 0x9058, { 8, 8, 6, 6}}, - {m68k_op_sub_16_er_pd , 0xf1f8, 0x9060, { 10, 10, 7, 7}}, - {m68k_op_sub_16_er_di , 0xf1f8, 0x9068, { 12, 12, 7, 7}}, - {m68k_op_sub_16_er_ix , 0xf1f8, 0x9070, { 14, 14, 9, 9}}, - {m68k_op_sub_32_er_d , 0xf1f8, 0x9080, { 8, 6, 2, 2}}, - {m68k_op_sub_32_er_a , 0xf1f8, 0x9088, { 8, 6, 2, 2}}, - {m68k_op_sub_32_er_ai , 0xf1f8, 0x9090, { 14, 14, 6, 6}}, - {m68k_op_sub_32_er_pi , 0xf1f8, 0x9098, { 14, 14, 6, 6}}, - {m68k_op_sub_32_er_pd , 0xf1f8, 0x90a0, { 16, 16, 7, 7}}, - {m68k_op_sub_32_er_di , 0xf1f8, 0x90a8, { 18, 18, 7, 7}}, - {m68k_op_sub_32_er_ix , 0xf1f8, 0x90b0, { 20, 20, 9, 9}}, - {m68k_op_suba_16_d , 0xf1f8, 0x90c0, { 8, 8, 2, 2}}, - {m68k_op_suba_16_a , 0xf1f8, 0x90c8, { 8, 8, 2, 2}}, - {m68k_op_suba_16_ai , 0xf1f8, 0x90d0, { 12, 12, 6, 6}}, - {m68k_op_suba_16_pi , 0xf1f8, 0x90d8, { 12, 12, 6, 6}}, - {m68k_op_suba_16_pd , 0xf1f8, 0x90e0, { 14, 14, 7, 7}}, - {m68k_op_suba_16_di , 0xf1f8, 0x90e8, { 16, 16, 7, 7}}, - {m68k_op_suba_16_ix , 0xf1f8, 0x90f0, { 18, 18, 9, 9}}, - {m68k_op_subx_8_rr , 0xf1f8, 0x9100, { 4, 4, 2, 2}}, - {m68k_op_subx_8_mm , 0xf1f8, 0x9108, { 18, 18, 12, 12}}, - {m68k_op_sub_8_re_ai , 0xf1f8, 0x9110, { 12, 12, 8, 8}}, - {m68k_op_sub_8_re_pi , 0xf1f8, 0x9118, { 12, 12, 8, 8}}, - {m68k_op_sub_8_re_pd , 0xf1f8, 0x9120, { 14, 14, 9, 9}}, - {m68k_op_sub_8_re_di , 0xf1f8, 0x9128, { 16, 16, 9, 9}}, - {m68k_op_sub_8_re_ix , 0xf1f8, 0x9130, { 18, 18, 11, 11}}, - {m68k_op_subx_16_rr , 0xf1f8, 0x9140, { 4, 4, 2, 2}}, - {m68k_op_subx_16_mm , 0xf1f8, 0x9148, { 18, 18, 12, 12}}, - {m68k_op_sub_16_re_ai , 0xf1f8, 0x9150, { 12, 12, 8, 8}}, - {m68k_op_sub_16_re_pi , 0xf1f8, 0x9158, { 12, 12, 8, 8}}, - {m68k_op_sub_16_re_pd , 0xf1f8, 0x9160, { 14, 14, 9, 9}}, - {m68k_op_sub_16_re_di , 0xf1f8, 0x9168, { 16, 16, 9, 9}}, - {m68k_op_sub_16_re_ix , 0xf1f8, 0x9170, { 18, 18, 11, 11}}, - {m68k_op_subx_32_rr , 0xf1f8, 0x9180, { 8, 6, 2, 2}}, - {m68k_op_subx_32_mm , 0xf1f8, 0x9188, { 30, 30, 12, 12}}, - {m68k_op_sub_32_re_ai , 0xf1f8, 0x9190, { 20, 20, 8, 8}}, - {m68k_op_sub_32_re_pi , 0xf1f8, 0x9198, { 20, 20, 8, 8}}, - {m68k_op_sub_32_re_pd , 0xf1f8, 0x91a0, { 22, 22, 9, 9}}, - {m68k_op_sub_32_re_di , 0xf1f8, 0x91a8, { 24, 24, 9, 9}}, - {m68k_op_sub_32_re_ix , 0xf1f8, 0x91b0, { 26, 26, 11, 11}}, - {m68k_op_suba_32_d , 0xf1f8, 0x91c0, { 8, 6, 2, 2}}, - {m68k_op_suba_32_a , 0xf1f8, 0x91c8, { 8, 6, 2, 2}}, - {m68k_op_suba_32_ai , 0xf1f8, 0x91d0, { 14, 14, 6, 6}}, - {m68k_op_suba_32_pi , 0xf1f8, 0x91d8, { 14, 14, 6, 6}}, - {m68k_op_suba_32_pd , 0xf1f8, 0x91e0, { 16, 16, 7, 7}}, - {m68k_op_suba_32_di , 0xf1f8, 0x91e8, { 18, 18, 7, 7}}, - {m68k_op_suba_32_ix , 0xf1f8, 0x91f0, { 20, 20, 9, 9}}, - {m68k_op_cmp_8_d , 0xf1f8, 0xb000, { 4, 4, 2, 2}}, - {m68k_op_cmp_8_ai , 0xf1f8, 0xb010, { 8, 8, 6, 6}}, - {m68k_op_cmp_8_pi , 0xf1f8, 0xb018, { 8, 8, 6, 6}}, - {m68k_op_cmp_8_pd , 0xf1f8, 0xb020, { 10, 10, 7, 7}}, - {m68k_op_cmp_8_di , 0xf1f8, 0xb028, { 12, 12, 7, 7}}, - {m68k_op_cmp_8_ix , 0xf1f8, 0xb030, { 14, 14, 9, 9}}, - {m68k_op_cmp_16_d , 0xf1f8, 0xb040, { 4, 4, 2, 2}}, - {m68k_op_cmp_16_a , 0xf1f8, 0xb048, { 4, 4, 2, 2}}, - {m68k_op_cmp_16_ai , 0xf1f8, 0xb050, { 8, 8, 6, 6}}, - {m68k_op_cmp_16_pi , 0xf1f8, 0xb058, { 8, 8, 6, 6}}, - {m68k_op_cmp_16_pd , 0xf1f8, 0xb060, { 10, 10, 7, 7}}, - {m68k_op_cmp_16_di , 0xf1f8, 0xb068, { 12, 12, 7, 7}}, - {m68k_op_cmp_16_ix , 0xf1f8, 0xb070, { 14, 14, 9, 9}}, - {m68k_op_cmp_32_d , 0xf1f8, 0xb080, { 6, 6, 2, 2}}, - {m68k_op_cmp_32_a , 0xf1f8, 0xb088, { 6, 6, 2, 2}}, - {m68k_op_cmp_32_ai , 0xf1f8, 0xb090, { 14, 14, 6, 6}}, - {m68k_op_cmp_32_pi , 0xf1f8, 0xb098, { 14, 14, 6, 6}}, - {m68k_op_cmp_32_pd , 0xf1f8, 0xb0a0, { 16, 16, 7, 7}}, - {m68k_op_cmp_32_di , 0xf1f8, 0xb0a8, { 18, 18, 7, 7}}, - {m68k_op_cmp_32_ix , 0xf1f8, 0xb0b0, { 20, 20, 9, 9}}, - {m68k_op_cmpa_16_d , 0xf1f8, 0xb0c0, { 6, 6, 4, 4}}, - {m68k_op_cmpa_16_a , 0xf1f8, 0xb0c8, { 6, 6, 4, 4}}, - {m68k_op_cmpa_16_ai , 0xf1f8, 0xb0d0, { 10, 10, 8, 8}}, - {m68k_op_cmpa_16_pi , 0xf1f8, 0xb0d8, { 10, 10, 8, 8}}, - {m68k_op_cmpa_16_pd , 0xf1f8, 0xb0e0, { 12, 12, 9, 9}}, - {m68k_op_cmpa_16_di , 0xf1f8, 0xb0e8, { 14, 14, 9, 9}}, - {m68k_op_cmpa_16_ix , 0xf1f8, 0xb0f0, { 16, 16, 11, 11}}, - {m68k_op_eor_8_d , 0xf1f8, 0xb100, { 4, 4, 2, 2}}, - {m68k_op_cmpm_8 , 0xf1f8, 0xb108, { 12, 12, 9, 9}}, - {m68k_op_eor_8_ai , 0xf1f8, 0xb110, { 12, 12, 8, 8}}, - {m68k_op_eor_8_pi , 0xf1f8, 0xb118, { 12, 12, 8, 8}}, - {m68k_op_eor_8_pd , 0xf1f8, 0xb120, { 14, 14, 9, 9}}, - {m68k_op_eor_8_di , 0xf1f8, 0xb128, { 16, 16, 9, 9}}, - {m68k_op_eor_8_ix , 0xf1f8, 0xb130, { 18, 18, 11, 11}}, - {m68k_op_eor_16_d , 0xf1f8, 0xb140, { 4, 4, 2, 2}}, - {m68k_op_cmpm_16 , 0xf1f8, 0xb148, { 12, 12, 9, 9}}, - {m68k_op_eor_16_ai , 0xf1f8, 0xb150, { 12, 12, 8, 8}}, - {m68k_op_eor_16_pi , 0xf1f8, 0xb158, { 12, 12, 8, 8}}, - {m68k_op_eor_16_pd , 0xf1f8, 0xb160, { 14, 14, 9, 9}}, - {m68k_op_eor_16_di , 0xf1f8, 0xb168, { 16, 16, 9, 9}}, - {m68k_op_eor_16_ix , 0xf1f8, 0xb170, { 18, 18, 11, 11}}, - {m68k_op_eor_32_d , 0xf1f8, 0xb180, { 8, 6, 2, 2}}, - {m68k_op_cmpm_32 , 0xf1f8, 0xb188, { 20, 20, 9, 9}}, - {m68k_op_eor_32_ai , 0xf1f8, 0xb190, { 20, 20, 8, 8}}, - {m68k_op_eor_32_pi , 0xf1f8, 0xb198, { 20, 20, 8, 8}}, - {m68k_op_eor_32_pd , 0xf1f8, 0xb1a0, { 22, 22, 9, 9}}, - {m68k_op_eor_32_di , 0xf1f8, 0xb1a8, { 24, 24, 9, 9}}, - {m68k_op_eor_32_ix , 0xf1f8, 0xb1b0, { 26, 26, 11, 11}}, - {m68k_op_cmpa_32_d , 0xf1f8, 0xb1c0, { 6, 6, 4, 4}}, - {m68k_op_cmpa_32_a , 0xf1f8, 0xb1c8, { 6, 6, 4, 4}}, - {m68k_op_cmpa_32_ai , 0xf1f8, 0xb1d0, { 14, 14, 8, 8}}, - {m68k_op_cmpa_32_pi , 0xf1f8, 0xb1d8, { 14, 14, 8, 8}}, - {m68k_op_cmpa_32_pd , 0xf1f8, 0xb1e0, { 16, 16, 9, 9}}, - {m68k_op_cmpa_32_di , 0xf1f8, 0xb1e8, { 18, 18, 9, 9}}, - {m68k_op_cmpa_32_ix , 0xf1f8, 0xb1f0, { 20, 20, 11, 11}}, - {m68k_op_and_8_er_d , 0xf1f8, 0xc000, { 4, 4, 2, 2}}, - {m68k_op_and_8_er_ai , 0xf1f8, 0xc010, { 8, 8, 6, 6}}, - {m68k_op_and_8_er_pi , 0xf1f8, 0xc018, { 8, 8, 6, 6}}, - {m68k_op_and_8_er_pd , 0xf1f8, 0xc020, { 10, 10, 7, 7}}, - {m68k_op_and_8_er_di , 0xf1f8, 0xc028, { 12, 12, 7, 7}}, - {m68k_op_and_8_er_ix , 0xf1f8, 0xc030, { 14, 14, 9, 9}}, - {m68k_op_and_16_er_d , 0xf1f8, 0xc040, { 4, 4, 2, 2}}, - {m68k_op_and_16_er_ai , 0xf1f8, 0xc050, { 8, 8, 6, 6}}, - {m68k_op_and_16_er_pi , 0xf1f8, 0xc058, { 8, 8, 6, 6}}, - {m68k_op_and_16_er_pd , 0xf1f8, 0xc060, { 10, 10, 7, 7}}, - {m68k_op_and_16_er_di , 0xf1f8, 0xc068, { 12, 12, 7, 7}}, - {m68k_op_and_16_er_ix , 0xf1f8, 0xc070, { 14, 14, 9, 9}}, - {m68k_op_and_32_er_d , 0xf1f8, 0xc080, { 8, 6, 2, 2}}, - {m68k_op_and_32_er_ai , 0xf1f8, 0xc090, { 14, 14, 6, 6}}, - {m68k_op_and_32_er_pi , 0xf1f8, 0xc098, { 14, 14, 6, 6}}, - {m68k_op_and_32_er_pd , 0xf1f8, 0xc0a0, { 16, 16, 7, 7}}, - {m68k_op_and_32_er_di , 0xf1f8, 0xc0a8, { 18, 18, 7, 7}}, - {m68k_op_and_32_er_ix , 0xf1f8, 0xc0b0, { 20, 20, 9, 9}}, - {m68k_op_mulu_16_d , 0xf1f8, 0xc0c0, { 0, 30, 27, 27}}, - {m68k_op_mulu_16_ai , 0xf1f8, 0xc0d0, { 4, 34, 31, 31}}, - {m68k_op_mulu_16_pi , 0xf1f8, 0xc0d8, { 4, 34, 31, 31}}, - {m68k_op_mulu_16_pd , 0xf1f8, 0xc0e0, { 6, 36, 32, 32}}, - {m68k_op_mulu_16_di , 0xf1f8, 0xc0e8, { 8, 38, 32, 32}}, - {m68k_op_mulu_16_ix , 0xf1f8, 0xc0f0, { 10, 40, 34, 34}}, - {m68k_op_abcd_8_rr , 0xf1f8, 0xc100, { 6, 6, 4, 4}}, - {m68k_op_abcd_8_mm , 0xf1f8, 0xc108, { 18, 18, 16, 16}}, - {m68k_op_and_8_re_ai , 0xf1f8, 0xc110, { 12, 12, 8, 8}}, - {m68k_op_and_8_re_pi , 0xf1f8, 0xc118, { 12, 12, 8, 8}}, - {m68k_op_and_8_re_pd , 0xf1f8, 0xc120, { 14, 14, 9, 9}}, - {m68k_op_and_8_re_di , 0xf1f8, 0xc128, { 16, 16, 9, 9}}, - {m68k_op_and_8_re_ix , 0xf1f8, 0xc130, { 18, 18, 11, 11}}, - {m68k_op_exg_32_dd , 0xf1f8, 0xc140, { 6, 6, 2, 2}}, - {m68k_op_exg_32_aa , 0xf1f8, 0xc148, { 6, 6, 2, 2}}, - {m68k_op_and_16_re_ai , 0xf1f8, 0xc150, { 12, 12, 8, 8}}, - {m68k_op_and_16_re_pi , 0xf1f8, 0xc158, { 12, 12, 8, 8}}, - {m68k_op_and_16_re_pd , 0xf1f8, 0xc160, { 14, 14, 9, 9}}, - {m68k_op_and_16_re_di , 0xf1f8, 0xc168, { 16, 16, 9, 9}}, - {m68k_op_and_16_re_ix , 0xf1f8, 0xc170, { 18, 18, 11, 11}}, - {m68k_op_exg_32_da , 0xf1f8, 0xc188, { 6, 6, 2, 2}}, - {m68k_op_and_32_re_ai , 0xf1f8, 0xc190, { 20, 20, 8, 8}}, - {m68k_op_and_32_re_pi , 0xf1f8, 0xc198, { 20, 20, 8, 8}}, - {m68k_op_and_32_re_pd , 0xf1f8, 0xc1a0, { 22, 22, 9, 9}}, - {m68k_op_and_32_re_di , 0xf1f8, 0xc1a8, { 24, 24, 9, 9}}, - {m68k_op_and_32_re_ix , 0xf1f8, 0xc1b0, { 26, 26, 11, 11}}, - {m68k_op_muls_16_d , 0xf1f8, 0xc1c0, { 0, 32, 27, 27}}, - {m68k_op_muls_16_ai , 0xf1f8, 0xc1d0, { 4, 36, 31, 31}}, - {m68k_op_muls_16_pi , 0xf1f8, 0xc1d8, { 4, 36, 31, 31}}, - {m68k_op_muls_16_pd , 0xf1f8, 0xc1e0, { 6, 38, 32, 32}}, - {m68k_op_muls_16_di , 0xf1f8, 0xc1e8, { 8, 40, 32, 32}}, - {m68k_op_muls_16_ix , 0xf1f8, 0xc1f0, { 10, 42, 34, 34}}, - {m68k_op_add_8_er_d , 0xf1f8, 0xd000, { 4, 4, 2, 2}}, - {m68k_op_add_8_er_ai , 0xf1f8, 0xd010, { 8, 8, 6, 6}}, - {m68k_op_add_8_er_pi , 0xf1f8, 0xd018, { 8, 8, 6, 6}}, - {m68k_op_add_8_er_pd , 0xf1f8, 0xd020, { 10, 10, 7, 7}}, - {m68k_op_add_8_er_di , 0xf1f8, 0xd028, { 12, 12, 7, 7}}, - {m68k_op_add_8_er_ix , 0xf1f8, 0xd030, { 14, 14, 9, 9}}, - {m68k_op_add_16_er_d , 0xf1f8, 0xd040, { 4, 4, 2, 2}}, - {m68k_op_add_16_er_a , 0xf1f8, 0xd048, { 4, 4, 2, 2}}, - {m68k_op_add_16_er_ai , 0xf1f8, 0xd050, { 8, 8, 6, 6}}, - {m68k_op_add_16_er_pi , 0xf1f8, 0xd058, { 8, 8, 6, 6}}, - {m68k_op_add_16_er_pd , 0xf1f8, 0xd060, { 10, 10, 7, 7}}, - {m68k_op_add_16_er_di , 0xf1f8, 0xd068, { 12, 12, 7, 7}}, - {m68k_op_add_16_er_ix , 0xf1f8, 0xd070, { 14, 14, 9, 9}}, - {m68k_op_add_32_er_d , 0xf1f8, 0xd080, { 8, 6, 2, 2}}, - {m68k_op_add_32_er_a , 0xf1f8, 0xd088, { 8, 6, 2, 2}}, - {m68k_op_add_32_er_ai , 0xf1f8, 0xd090, { 14, 14, 6, 6}}, - {m68k_op_add_32_er_pi , 0xf1f8, 0xd098, { 14, 14, 6, 6}}, - {m68k_op_add_32_er_pd , 0xf1f8, 0xd0a0, { 16, 16, 7, 7}}, - {m68k_op_add_32_er_di , 0xf1f8, 0xd0a8, { 18, 18, 7, 7}}, - {m68k_op_add_32_er_ix , 0xf1f8, 0xd0b0, { 20, 20, 9, 9}}, - {m68k_op_adda_16_d , 0xf1f8, 0xd0c0, { 8, 8, 2, 2}}, - {m68k_op_adda_16_a , 0xf1f8, 0xd0c8, { 8, 8, 2, 2}}, - {m68k_op_adda_16_ai , 0xf1f8, 0xd0d0, { 12, 12, 6, 6}}, - {m68k_op_adda_16_pi , 0xf1f8, 0xd0d8, { 12, 12, 6, 6}}, - {m68k_op_adda_16_pd , 0xf1f8, 0xd0e0, { 14, 14, 7, 7}}, - {m68k_op_adda_16_di , 0xf1f8, 0xd0e8, { 16, 16, 7, 7}}, - {m68k_op_adda_16_ix , 0xf1f8, 0xd0f0, { 18, 18, 9, 9}}, - {m68k_op_addx_8_rr , 0xf1f8, 0xd100, { 4, 4, 2, 2}}, - {m68k_op_addx_8_mm , 0xf1f8, 0xd108, { 18, 18, 12, 12}}, - {m68k_op_add_8_re_ai , 0xf1f8, 0xd110, { 12, 12, 8, 8}}, - {m68k_op_add_8_re_pi , 0xf1f8, 0xd118, { 12, 12, 8, 8}}, - {m68k_op_add_8_re_pd , 0xf1f8, 0xd120, { 14, 14, 9, 9}}, - {m68k_op_add_8_re_di , 0xf1f8, 0xd128, { 16, 16, 9, 9}}, - {m68k_op_add_8_re_ix , 0xf1f8, 0xd130, { 18, 18, 11, 11}}, - {m68k_op_addx_16_rr , 0xf1f8, 0xd140, { 4, 4, 2, 2}}, - {m68k_op_addx_16_mm , 0xf1f8, 0xd148, { 18, 18, 12, 12}}, - {m68k_op_add_16_re_ai , 0xf1f8, 0xd150, { 12, 12, 8, 8}}, - {m68k_op_add_16_re_pi , 0xf1f8, 0xd158, { 12, 12, 8, 8}}, - {m68k_op_add_16_re_pd , 0xf1f8, 0xd160, { 14, 14, 9, 9}}, - {m68k_op_add_16_re_di , 0xf1f8, 0xd168, { 16, 16, 9, 9}}, - {m68k_op_add_16_re_ix , 0xf1f8, 0xd170, { 18, 18, 11, 11}}, - {m68k_op_addx_32_rr , 0xf1f8, 0xd180, { 8, 6, 2, 2}}, - {m68k_op_addx_32_mm , 0xf1f8, 0xd188, { 30, 30, 12, 12}}, - {m68k_op_add_32_re_ai , 0xf1f8, 0xd190, { 20, 20, 8, 8}}, - {m68k_op_add_32_re_pi , 0xf1f8, 0xd198, { 20, 20, 8, 8}}, - {m68k_op_add_32_re_pd , 0xf1f8, 0xd1a0, { 22, 22, 9, 9}}, - {m68k_op_add_32_re_di , 0xf1f8, 0xd1a8, { 24, 24, 9, 9}}, - {m68k_op_add_32_re_ix , 0xf1f8, 0xd1b0, { 26, 26, 11, 11}}, - {m68k_op_adda_32_d , 0xf1f8, 0xd1c0, { 8, 6, 2, 2}}, - {m68k_op_adda_32_a , 0xf1f8, 0xd1c8, { 8, 6, 2, 2}}, - {m68k_op_adda_32_ai , 0xf1f8, 0xd1d0, { 14, 14, 6, 6}}, - {m68k_op_adda_32_pi , 0xf1f8, 0xd1d8, { 14, 14, 6, 6}}, - {m68k_op_adda_32_pd , 0xf1f8, 0xd1e0, { 16, 16, 7, 7}}, - {m68k_op_adda_32_di , 0xf1f8, 0xd1e8, { 18, 18, 7, 7}}, - {m68k_op_adda_32_ix , 0xf1f8, 0xd1f0, { 20, 20, 9, 9}}, - {m68k_op_asr_8_s , 0xf1f8, 0xe000, { 6, 6, 6, 6}}, - {m68k_op_lsr_8_s , 0xf1f8, 0xe008, { 6, 6, 4, 4}}, - {m68k_op_roxr_8_s , 0xf1f8, 0xe010, { 6, 6, 12, 12}}, - {m68k_op_ror_8_s , 0xf1f8, 0xe018, { 6, 6, 8, 8}}, - {m68k_op_asr_8_r , 0xf1f8, 0xe020, { 6, 6, 6, 6}}, - {m68k_op_lsr_8_r , 0xf1f8, 0xe028, { 6, 6, 6, 6}}, - {m68k_op_roxr_8_r , 0xf1f8, 0xe030, { 6, 6, 12, 12}}, - {m68k_op_ror_8_r , 0xf1f8, 0xe038, { 6, 6, 8, 8}}, - {m68k_op_asr_16_s , 0xf1f8, 0xe040, { 6, 6, 6, 6}}, - {m68k_op_lsr_16_s , 0xf1f8, 0xe048, { 6, 6, 4, 4}}, - {m68k_op_roxr_16_s , 0xf1f8, 0xe050, { 6, 6, 12, 12}}, - {m68k_op_ror_16_s , 0xf1f8, 0xe058, { 6, 6, 8, 8}}, - {m68k_op_asr_16_r , 0xf1f8, 0xe060, { 6, 6, 6, 6}}, - {m68k_op_lsr_16_r , 0xf1f8, 0xe068, { 6, 6, 6, 6}}, - {m68k_op_roxr_16_r , 0xf1f8, 0xe070, { 6, 6, 12, 12}}, - {m68k_op_ror_16_r , 0xf1f8, 0xe078, { 6, 6, 8, 8}}, - {m68k_op_asr_32_s , 0xf1f8, 0xe080, { 8, 8, 6, 6}}, - {m68k_op_lsr_32_s , 0xf1f8, 0xe088, { 8, 8, 4, 4}}, - {m68k_op_roxr_32_s , 0xf1f8, 0xe090, { 8, 8, 12, 12}}, - {m68k_op_ror_32_s , 0xf1f8, 0xe098, { 8, 8, 8, 8}}, - {m68k_op_asr_32_r , 0xf1f8, 0xe0a0, { 8, 8, 6, 6}}, - {m68k_op_lsr_32_r , 0xf1f8, 0xe0a8, { 8, 8, 6, 6}}, - {m68k_op_roxr_32_r , 0xf1f8, 0xe0b0, { 8, 8, 12, 12}}, - {m68k_op_ror_32_r , 0xf1f8, 0xe0b8, { 8, 8, 8, 8}}, - {m68k_op_asl_8_s , 0xf1f8, 0xe100, { 6, 6, 8, 8}}, - {m68k_op_lsl_8_s , 0xf1f8, 0xe108, { 6, 6, 4, 4}}, - {m68k_op_roxl_8_s , 0xf1f8, 0xe110, { 6, 6, 12, 12}}, - {m68k_op_rol_8_s , 0xf1f8, 0xe118, { 6, 6, 8, 8}}, - {m68k_op_asl_8_r , 0xf1f8, 0xe120, { 6, 6, 8, 8}}, - {m68k_op_lsl_8_r , 0xf1f8, 0xe128, { 6, 6, 6, 6}}, - {m68k_op_roxl_8_r , 0xf1f8, 0xe130, { 6, 6, 12, 12}}, - {m68k_op_rol_8_r , 0xf1f8, 0xe138, { 6, 6, 8, 8}}, - {m68k_op_asl_16_s , 0xf1f8, 0xe140, { 6, 6, 8, 8}}, - {m68k_op_lsl_16_s , 0xf1f8, 0xe148, { 6, 6, 4, 4}}, - {m68k_op_roxl_16_s , 0xf1f8, 0xe150, { 6, 6, 12, 12}}, - {m68k_op_rol_16_s , 0xf1f8, 0xe158, { 6, 6, 8, 8}}, - {m68k_op_asl_16_r , 0xf1f8, 0xe160, { 6, 6, 8, 8}}, - {m68k_op_lsl_16_r , 0xf1f8, 0xe168, { 6, 6, 6, 6}}, - {m68k_op_roxl_16_r , 0xf1f8, 0xe170, { 6, 6, 12, 12}}, - {m68k_op_rol_16_r , 0xf1f8, 0xe178, { 6, 6, 8, 8}}, - {m68k_op_asl_32_s , 0xf1f8, 0xe180, { 8, 8, 8, 8}}, - {m68k_op_lsl_32_s , 0xf1f8, 0xe188, { 8, 8, 4, 4}}, - {m68k_op_roxl_32_s , 0xf1f8, 0xe190, { 8, 8, 12, 12}}, - {m68k_op_rol_32_s , 0xf1f8, 0xe198, { 8, 8, 8, 8}}, - {m68k_op_asl_32_r , 0xf1f8, 0xe1a0, { 8, 8, 8, 8}}, - {m68k_op_lsl_32_r , 0xf1f8, 0xe1a8, { 8, 8, 6, 6}}, - {m68k_op_roxl_32_r , 0xf1f8, 0xe1b0, { 8, 8, 12, 12}}, - {m68k_op_rol_32_r , 0xf1f8, 0xe1b8, { 8, 8, 8, 8}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cpdbcc_32 , 0xf1f8, 0xf048, { 0, 0, 4, 0}}, - {m68k_op_cptrapcc_32 , 0xf1f8, 0xf078, { 0, 0, 4, 0}}, - {m68k_op_rtm_32 , 0xfff0, 0x06c0, { 0, 0, 19, 19}}, -#endif - {m68k_op_trap , 0xfff0, 0x4e40, { 4, 4, 4, 4}}, - {m68k_op_btst_8_r_pi7 , 0xf1ff, 0x011f, { 8, 8, 8, 8}}, - {m68k_op_btst_8_r_pd7 , 0xf1ff, 0x0127, { 10, 10, 9, 9}}, - {m68k_op_btst_8_r_aw , 0xf1ff, 0x0138, { 12, 12, 8, 8}}, - {m68k_op_btst_8_r_al , 0xf1ff, 0x0139, { 16, 16, 8, 8}}, - {m68k_op_btst_8_r_pcdi , 0xf1ff, 0x013a, { 12, 12, 9, 9}}, - {m68k_op_btst_8_r_pcix , 0xf1ff, 0x013b, { 14, 14, 11, 11}}, - {m68k_op_btst_8_r_i , 0xf1ff, 0x013c, { 8, 8, 6, 6}}, - {m68k_op_bchg_8_r_pi7 , 0xf1ff, 0x015f, { 12, 12, 8, 8}}, - {m68k_op_bchg_8_r_pd7 , 0xf1ff, 0x0167, { 14, 14, 9, 9}}, - {m68k_op_bchg_8_r_aw , 0xf1ff, 0x0178, { 16, 16, 8, 8}}, - {m68k_op_bchg_8_r_al , 0xf1ff, 0x0179, { 20, 20, 8, 8}}, - {m68k_op_bclr_8_r_pi7 , 0xf1ff, 0x019f, { 12, 14, 8, 8}}, - {m68k_op_bclr_8_r_pd7 , 0xf1ff, 0x01a7, { 14, 16, 9, 9}}, - {m68k_op_bclr_8_r_aw , 0xf1ff, 0x01b8, { 16, 18, 8, 8}}, - {m68k_op_bclr_8_r_al , 0xf1ff, 0x01b9, { 20, 22, 8, 8}}, - {m68k_op_bset_8_r_pi7 , 0xf1ff, 0x01df, { 12, 12, 8, 8}}, - {m68k_op_bset_8_r_pd7 , 0xf1ff, 0x01e7, { 14, 14, 9, 9}}, - {m68k_op_bset_8_r_aw , 0xf1ff, 0x01f8, { 16, 16, 8, 8}}, - {m68k_op_bset_8_r_al , 0xf1ff, 0x01f9, { 20, 20, 8, 8}}, - {m68k_op_move_8_d_pi7 , 0xf1ff, 0x101f, { 8, 8, 6, 6}}, - {m68k_op_move_8_d_pd7 , 0xf1ff, 0x1027, { 10, 10, 7, 7}}, - {m68k_op_move_8_d_aw , 0xf1ff, 0x1038, { 12, 12, 6, 6}}, - {m68k_op_move_8_d_al , 0xf1ff, 0x1039, { 16, 16, 6, 6}}, - {m68k_op_move_8_d_pcdi , 0xf1ff, 0x103a, { 12, 12, 7, 7}}, - {m68k_op_move_8_d_pcix , 0xf1ff, 0x103b, { 14, 14, 9, 9}}, - {m68k_op_move_8_d_i , 0xf1ff, 0x103c, { 8, 8, 4, 4}}, - {m68k_op_move_8_ai_pi7 , 0xf1ff, 0x109f, { 12, 12, 8, 8}}, - {m68k_op_move_8_ai_pd7 , 0xf1ff, 0x10a7, { 14, 14, 9, 9}}, - {m68k_op_move_8_ai_aw , 0xf1ff, 0x10b8, { 16, 16, 8, 8}}, - {m68k_op_move_8_ai_al , 0xf1ff, 0x10b9, { 20, 20, 8, 8}}, - {m68k_op_move_8_ai_pcdi , 0xf1ff, 0x10ba, { 16, 16, 9, 9}}, - {m68k_op_move_8_ai_pcix , 0xf1ff, 0x10bb, { 18, 18, 11, 11}}, - {m68k_op_move_8_ai_i , 0xf1ff, 0x10bc, { 12, 12, 6, 6}}, - {m68k_op_move_8_pi_pi7 , 0xf1ff, 0x10df, { 12, 12, 8, 8}}, - {m68k_op_move_8_pi_pd7 , 0xf1ff, 0x10e7, { 14, 14, 9, 9}}, - {m68k_op_move_8_pi_aw , 0xf1ff, 0x10f8, { 16, 16, 8, 8}}, - {m68k_op_move_8_pi_al , 0xf1ff, 0x10f9, { 20, 20, 8, 8}}, - {m68k_op_move_8_pi_pcdi , 0xf1ff, 0x10fa, { 16, 16, 9, 9}}, - {m68k_op_move_8_pi_pcix , 0xf1ff, 0x10fb, { 18, 18, 11, 11}}, - {m68k_op_move_8_pi_i , 0xf1ff, 0x10fc, { 12, 12, 6, 6}}, - {m68k_op_move_8_pd_pi7 , 0xf1ff, 0x111f, { 12, 12, 9, 9}}, - {m68k_op_move_8_pd_pd7 , 0xf1ff, 0x1127, { 14, 14, 10, 10}}, - {m68k_op_move_8_pd_aw , 0xf1ff, 0x1138, { 16, 16, 9, 9}}, - {m68k_op_move_8_pd_al , 0xf1ff, 0x1139, { 20, 20, 9, 9}}, - {m68k_op_move_8_pd_pcdi , 0xf1ff, 0x113a, { 16, 16, 10, 10}}, - {m68k_op_move_8_pd_pcix , 0xf1ff, 0x113b, { 18, 18, 12, 12}}, - {m68k_op_move_8_pd_i , 0xf1ff, 0x113c, { 12, 12, 7, 7}}, - {m68k_op_move_8_di_pi7 , 0xf1ff, 0x115f, { 16, 16, 9, 9}}, - {m68k_op_move_8_di_pd7 , 0xf1ff, 0x1167, { 18, 18, 10, 10}}, - {m68k_op_move_8_di_aw , 0xf1ff, 0x1178, { 20, 20, 9, 9}}, - {m68k_op_move_8_di_al , 0xf1ff, 0x1179, { 24, 24, 9, 9}}, - {m68k_op_move_8_di_pcdi , 0xf1ff, 0x117a, { 20, 20, 10, 10}}, - {m68k_op_move_8_di_pcix , 0xf1ff, 0x117b, { 22, 22, 12, 12}}, - {m68k_op_move_8_di_i , 0xf1ff, 0x117c, { 16, 16, 7, 7}}, - {m68k_op_move_8_ix_pi7 , 0xf1ff, 0x119f, { 18, 18, 11, 11}}, - {m68k_op_move_8_ix_pd7 , 0xf1ff, 0x11a7, { 20, 20, 12, 12}}, - {m68k_op_move_8_ix_aw , 0xf1ff, 0x11b8, { 22, 22, 11, 11}}, - {m68k_op_move_8_ix_al , 0xf1ff, 0x11b9, { 26, 26, 11, 11}}, - {m68k_op_move_8_ix_pcdi , 0xf1ff, 0x11ba, { 22, 22, 12, 12}}, - {m68k_op_move_8_ix_pcix , 0xf1ff, 0x11bb, { 24, 24, 14, 14}}, - {m68k_op_move_8_ix_i , 0xf1ff, 0x11bc, { 18, 18, 9, 9}}, - {m68k_op_move_32_d_aw , 0xf1ff, 0x2038, { 16, 16, 6, 6}}, - {m68k_op_move_32_d_al , 0xf1ff, 0x2039, { 20, 20, 6, 6}}, - {m68k_op_move_32_d_pcdi , 0xf1ff, 0x203a, { 16, 16, 7, 7}}, - {m68k_op_move_32_d_pcix , 0xf1ff, 0x203b, { 18, 18, 9, 9}}, - {m68k_op_move_32_d_i , 0xf1ff, 0x203c, { 12, 12, 6, 6}}, - {m68k_op_movea_32_aw , 0xf1ff, 0x2078, { 16, 16, 6, 6}}, - {m68k_op_movea_32_al , 0xf1ff, 0x2079, { 20, 20, 6, 6}}, - {m68k_op_movea_32_pcdi , 0xf1ff, 0x207a, { 16, 16, 7, 7}}, - {m68k_op_movea_32_pcix , 0xf1ff, 0x207b, { 18, 18, 9, 9}}, - {m68k_op_movea_32_i , 0xf1ff, 0x207c, { 12, 12, 6, 6}}, - {m68k_op_move_32_ai_aw , 0xf1ff, 0x20b8, { 24, 24, 8, 8}}, - {m68k_op_move_32_ai_al , 0xf1ff, 0x20b9, { 28, 28, 8, 8}}, - {m68k_op_move_32_ai_pcdi , 0xf1ff, 0x20ba, { 24, 24, 9, 9}}, - {m68k_op_move_32_ai_pcix , 0xf1ff, 0x20bb, { 26, 26, 11, 11}}, - {m68k_op_move_32_ai_i , 0xf1ff, 0x20bc, { 20, 20, 8, 8}}, - {m68k_op_move_32_pi_aw , 0xf1ff, 0x20f8, { 24, 24, 8, 8}}, - {m68k_op_move_32_pi_al , 0xf1ff, 0x20f9, { 28, 28, 8, 8}}, - {m68k_op_move_32_pi_pcdi , 0xf1ff, 0x20fa, { 24, 24, 9, 9}}, - {m68k_op_move_32_pi_pcix , 0xf1ff, 0x20fb, { 26, 26, 11, 11}}, - {m68k_op_move_32_pi_i , 0xf1ff, 0x20fc, { 20, 20, 8, 8}}, - {m68k_op_move_32_pd_aw , 0xf1ff, 0x2138, { 24, 26, 9, 9}}, - {m68k_op_move_32_pd_al , 0xf1ff, 0x2139, { 28, 30, 9, 9}}, - {m68k_op_move_32_pd_pcdi , 0xf1ff, 0x213a, { 24, 26, 10, 10}}, - {m68k_op_move_32_pd_pcix , 0xf1ff, 0x213b, { 26, 28, 12, 12}}, - {m68k_op_move_32_pd_i , 0xf1ff, 0x213c, { 20, 22, 9, 9}}, - {m68k_op_move_32_di_aw , 0xf1ff, 0x2178, { 28, 28, 9, 9}}, - {m68k_op_move_32_di_al , 0xf1ff, 0x2179, { 32, 32, 9, 9}}, - {m68k_op_move_32_di_pcdi , 0xf1ff, 0x217a, { 28, 28, 10, 10}}, - {m68k_op_move_32_di_pcix , 0xf1ff, 0x217b, { 30, 30, 12, 12}}, - {m68k_op_move_32_di_i , 0xf1ff, 0x217c, { 24, 24, 9, 9}}, - {m68k_op_move_32_ix_aw , 0xf1ff, 0x21b8, { 30, 30, 11, 11}}, - {m68k_op_move_32_ix_al , 0xf1ff, 0x21b9, { 34, 34, 11, 11}}, - {m68k_op_move_32_ix_pcdi , 0xf1ff, 0x21ba, { 30, 30, 12, 12}}, - {m68k_op_move_32_ix_pcix , 0xf1ff, 0x21bb, { 32, 32, 14, 14}}, - {m68k_op_move_32_ix_i , 0xf1ff, 0x21bc, { 26, 26, 11, 11}}, - {m68k_op_move_16_d_aw , 0xf1ff, 0x3038, { 12, 12, 6, 6}}, - {m68k_op_move_16_d_al , 0xf1ff, 0x3039, { 16, 16, 6, 6}}, - {m68k_op_move_16_d_pcdi , 0xf1ff, 0x303a, { 12, 12, 7, 7}}, - {m68k_op_move_16_d_pcix , 0xf1ff, 0x303b, { 14, 14, 9, 9}}, - {m68k_op_move_16_d_i , 0xf1ff, 0x303c, { 8, 8, 4, 4}}, - {m68k_op_movea_16_aw , 0xf1ff, 0x3078, { 12, 12, 6, 6}}, - {m68k_op_movea_16_al , 0xf1ff, 0x3079, { 16, 16, 6, 6}}, - {m68k_op_movea_16_pcdi , 0xf1ff, 0x307a, { 12, 12, 7, 7}}, - {m68k_op_movea_16_pcix , 0xf1ff, 0x307b, { 14, 14, 9, 9}}, - {m68k_op_movea_16_i , 0xf1ff, 0x307c, { 8, 8, 4, 4}}, - {m68k_op_move_16_ai_aw , 0xf1ff, 0x30b8, { 16, 16, 8, 8}}, - {m68k_op_move_16_ai_al , 0xf1ff, 0x30b9, { 20, 20, 8, 8}}, - {m68k_op_move_16_ai_pcdi , 0xf1ff, 0x30ba, { 16, 16, 9, 9}}, - {m68k_op_move_16_ai_pcix , 0xf1ff, 0x30bb, { 18, 18, 11, 11}}, - {m68k_op_move_16_ai_i , 0xf1ff, 0x30bc, { 12, 12, 6, 6}}, - {m68k_op_move_16_pi_aw , 0xf1ff, 0x30f8, { 16, 16, 8, 8}}, - {m68k_op_move_16_pi_al , 0xf1ff, 0x30f9, { 20, 20, 8, 8}}, - {m68k_op_move_16_pi_pcdi , 0xf1ff, 0x30fa, { 16, 16, 9, 9}}, - {m68k_op_move_16_pi_pcix , 0xf1ff, 0x30fb, { 18, 18, 11, 11}}, - {m68k_op_move_16_pi_i , 0xf1ff, 0x30fc, { 12, 12, 6, 6}}, - {m68k_op_move_16_pd_aw , 0xf1ff, 0x3138, { 16, 16, 9, 9}}, - {m68k_op_move_16_pd_al , 0xf1ff, 0x3139, { 20, 20, 9, 9}}, - {m68k_op_move_16_pd_pcdi , 0xf1ff, 0x313a, { 16, 16, 10, 10}}, - {m68k_op_move_16_pd_pcix , 0xf1ff, 0x313b, { 18, 18, 12, 12}}, - {m68k_op_move_16_pd_i , 0xf1ff, 0x313c, { 12, 12, 7, 7}}, - {m68k_op_move_16_di_aw , 0xf1ff, 0x3178, { 20, 20, 9, 9}}, - {m68k_op_move_16_di_al , 0xf1ff, 0x3179, { 24, 24, 9, 9}}, - {m68k_op_move_16_di_pcdi , 0xf1ff, 0x317a, { 20, 20, 10, 10}}, - {m68k_op_move_16_di_pcix , 0xf1ff, 0x317b, { 22, 22, 12, 12}}, - {m68k_op_move_16_di_i , 0xf1ff, 0x317c, { 16, 16, 7, 7}}, - {m68k_op_move_16_ix_aw , 0xf1ff, 0x31b8, { 22, 22, 11, 11}}, - {m68k_op_move_16_ix_al , 0xf1ff, 0x31b9, { 26, 26, 11, 11}}, - {m68k_op_move_16_ix_pcdi , 0xf1ff, 0x31ba, { 22, 22, 12, 12}}, - {m68k_op_move_16_ix_pcix , 0xf1ff, 0x31bb, { 24, 24, 14, 14}}, - {m68k_op_move_16_ix_i , 0xf1ff, 0x31bc, { 18, 18, 9, 9}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_chk_32_aw , 0xf1ff, 0x4138, { 0, 0, 12, 12}}, - {m68k_op_chk_32_al , 0xf1ff, 0x4139, { 0, 0, 12, 12}}, - {m68k_op_chk_32_pcdi , 0xf1ff, 0x413a, { 0, 0, 13, 13}}, - {m68k_op_chk_32_pcix , 0xf1ff, 0x413b, { 0, 0, 15, 15}}, - {m68k_op_chk_32_i , 0xf1ff, 0x413c, { 0, 0, 12, 12}}, -#endif - {m68k_op_chk_16_aw , 0xf1ff, 0x41b8, { 18, 16, 12, 12}}, - {m68k_op_chk_16_al , 0xf1ff, 0x41b9, { 22, 20, 12, 12}}, - {m68k_op_chk_16_pcdi , 0xf1ff, 0x41ba, { 18, 16, 13, 13}}, - {m68k_op_chk_16_pcix , 0xf1ff, 0x41bb, { 20, 18, 15, 15}}, - {m68k_op_chk_16_i , 0xf1ff, 0x41bc, { 14, 12, 10, 10}}, - {m68k_op_lea_32_aw , 0xf1ff, 0x41f8, { 8, 8, 6, 6}}, - {m68k_op_lea_32_al , 0xf1ff, 0x41f9, { 12, 12, 6, 6}}, - {m68k_op_lea_32_pcdi , 0xf1ff, 0x41fa, { 8, 8, 7, 7}}, - {m68k_op_lea_32_pcix , 0xf1ff, 0x41fb, { 12, 12, 9, 9}}, - {m68k_op_addq_8_pi7 , 0xf1ff, 0x501f, { 12, 12, 8, 8}}, - {m68k_op_addq_8_pd7 , 0xf1ff, 0x5027, { 14, 14, 9, 9}}, - {m68k_op_addq_8_aw , 0xf1ff, 0x5038, { 16, 16, 8, 8}}, - {m68k_op_addq_8_al , 0xf1ff, 0x5039, { 20, 20, 8, 8}}, - {m68k_op_addq_16_aw , 0xf1ff, 0x5078, { 16, 16, 8, 8}}, - {m68k_op_addq_16_al , 0xf1ff, 0x5079, { 20, 20, 8, 8}}, - {m68k_op_addq_32_aw , 0xf1ff, 0x50b8, { 24, 24, 8, 8}}, - {m68k_op_addq_32_al , 0xf1ff, 0x50b9, { 28, 28, 8, 8}}, - {m68k_op_subq_8_pi7 , 0xf1ff, 0x511f, { 12, 12, 8, 8}}, - {m68k_op_subq_8_pd7 , 0xf1ff, 0x5127, { 14, 14, 9, 9}}, - {m68k_op_subq_8_aw , 0xf1ff, 0x5138, { 16, 16, 8, 8}}, - {m68k_op_subq_8_al , 0xf1ff, 0x5139, { 20, 20, 8, 8}}, - {m68k_op_subq_16_aw , 0xf1ff, 0x5178, { 16, 16, 8, 8}}, - {m68k_op_subq_16_al , 0xf1ff, 0x5179, { 20, 20, 8, 8}}, - {m68k_op_subq_32_aw , 0xf1ff, 0x51b8, { 24, 24, 8, 8}}, - {m68k_op_subq_32_al , 0xf1ff, 0x51b9, { 28, 28, 8, 8}}, - {m68k_op_or_8_er_pi7 , 0xf1ff, 0x801f, { 8, 8, 6, 6}}, - {m68k_op_or_8_er_pd7 , 0xf1ff, 0x8027, { 10, 10, 7, 7}}, - {m68k_op_or_8_er_aw , 0xf1ff, 0x8038, { 12, 12, 6, 6}}, - {m68k_op_or_8_er_al , 0xf1ff, 0x8039, { 16, 16, 6, 6}}, - {m68k_op_or_8_er_pcdi , 0xf1ff, 0x803a, { 12, 12, 7, 7}}, - {m68k_op_or_8_er_pcix , 0xf1ff, 0x803b, { 14, 14, 9, 9}}, - {m68k_op_or_8_er_i , 0xf1ff, 0x803c, { 8, 8, 4, 4}}, - {m68k_op_or_16_er_aw , 0xf1ff, 0x8078, { 12, 12, 6, 6}}, - {m68k_op_or_16_er_al , 0xf1ff, 0x8079, { 16, 16, 6, 6}}, - {m68k_op_or_16_er_pcdi , 0xf1ff, 0x807a, { 12, 12, 7, 7}}, - {m68k_op_or_16_er_pcix , 0xf1ff, 0x807b, { 14, 14, 9, 9}}, - {m68k_op_or_16_er_i , 0xf1ff, 0x807c, { 8, 8, 4, 4}}, - {m68k_op_or_32_er_aw , 0xf1ff, 0x80b8, { 18, 18, 6, 6}}, - {m68k_op_or_32_er_al , 0xf1ff, 0x80b9, { 22, 22, 6, 6}}, - {m68k_op_or_32_er_pcdi , 0xf1ff, 0x80ba, { 18, 18, 7, 7}}, - {m68k_op_or_32_er_pcix , 0xf1ff, 0x80bb, { 20, 20, 9, 9}}, - {m68k_op_or_32_er_i , 0xf1ff, 0x80bc, { 16, 14, 6, 6}}, - {m68k_op_divu_16_aw , 0xf1ff, 0x80f8, { 8, 116, 48, 48}}, - {m68k_op_divu_16_al , 0xf1ff, 0x80f9, { 12, 120, 48, 48}}, - {m68k_op_divu_16_pcdi , 0xf1ff, 0x80fa, { 8, 116, 49, 49}}, - {m68k_op_divu_16_pcix , 0xf1ff, 0x80fb, { 10, 118, 51, 51}}, - {m68k_op_divu_16_i , 0xf1ff, 0x80fc, { 4, 112, 46, 46}}, - {m68k_op_sbcd_8_mm_ay7 , 0xf1ff, 0x810f, { 18, 18, 16, 16}}, - {m68k_op_or_8_re_pi7 , 0xf1ff, 0x811f, { 12, 12, 8, 8}}, - {m68k_op_or_8_re_pd7 , 0xf1ff, 0x8127, { 14, 14, 9, 9}}, - {m68k_op_or_8_re_aw , 0xf1ff, 0x8138, { 16, 16, 8, 8}}, - {m68k_op_or_8_re_al , 0xf1ff, 0x8139, { 20, 20, 8, 8}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_pack_16_mm_ay7 , 0xf1ff, 0x814f, { 0, 0, 13, 13}}, -#endif - {m68k_op_or_16_re_aw , 0xf1ff, 0x8178, { 16, 16, 8, 8}}, - {m68k_op_or_16_re_al , 0xf1ff, 0x8179, { 20, 20, 8, 8}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_unpk_16_mm_ay7 , 0xf1ff, 0x818f, { 0, 0, 13, 13}}, -#endif - {m68k_op_or_32_re_aw , 0xf1ff, 0x81b8, { 24, 24, 8, 8}}, - {m68k_op_or_32_re_al , 0xf1ff, 0x81b9, { 28, 28, 8, 8}}, - {m68k_op_divs_16_aw , 0xf1ff, 0x81f8, { 8, 130, 60, 60}}, - {m68k_op_divs_16_al , 0xf1ff, 0x81f9, { 12, 134, 60, 60}}, - {m68k_op_divs_16_pcdi , 0xf1ff, 0x81fa, { 8, 130, 61, 61}}, - {m68k_op_divs_16_pcix , 0xf1ff, 0x81fb, { 10, 132, 63, 63}}, - {m68k_op_divs_16_i , 0xf1ff, 0x81fc, { 4, 126, 58, 58}}, - {m68k_op_sub_8_er_pi7 , 0xf1ff, 0x901f, { 8, 8, 6, 6}}, - {m68k_op_sub_8_er_pd7 , 0xf1ff, 0x9027, { 10, 10, 7, 7}}, - {m68k_op_sub_8_er_aw , 0xf1ff, 0x9038, { 12, 12, 6, 6}}, - {m68k_op_sub_8_er_al , 0xf1ff, 0x9039, { 16, 16, 6, 6}}, - {m68k_op_sub_8_er_pcdi , 0xf1ff, 0x903a, { 12, 12, 7, 7}}, - {m68k_op_sub_8_er_pcix , 0xf1ff, 0x903b, { 14, 14, 9, 9}}, - {m68k_op_sub_8_er_i , 0xf1ff, 0x903c, { 8, 8, 4, 4}}, - {m68k_op_sub_16_er_aw , 0xf1ff, 0x9078, { 12, 12, 6, 6}}, - {m68k_op_sub_16_er_al , 0xf1ff, 0x9079, { 16, 16, 6, 6}}, - {m68k_op_sub_16_er_pcdi , 0xf1ff, 0x907a, { 12, 12, 7, 7}}, - {m68k_op_sub_16_er_pcix , 0xf1ff, 0x907b, { 14, 14, 9, 9}}, - {m68k_op_sub_16_er_i , 0xf1ff, 0x907c, { 8, 8, 4, 4}}, - {m68k_op_sub_32_er_aw , 0xf1ff, 0x90b8, { 18, 18, 6, 6}}, - {m68k_op_sub_32_er_al , 0xf1ff, 0x90b9, { 22, 22, 6, 6}}, - {m68k_op_sub_32_er_pcdi , 0xf1ff, 0x90ba, { 18, 18, 7, 7}}, - {m68k_op_sub_32_er_pcix , 0xf1ff, 0x90bb, { 20, 20, 9, 9}}, - {m68k_op_sub_32_er_i , 0xf1ff, 0x90bc, { 16, 14, 6, 6}}, - {m68k_op_suba_16_aw , 0xf1ff, 0x90f8, { 16, 16, 6, 6}}, - {m68k_op_suba_16_al , 0xf1ff, 0x90f9, { 20, 20, 6, 6}}, - {m68k_op_suba_16_pcdi , 0xf1ff, 0x90fa, { 16, 16, 7, 7}}, - {m68k_op_suba_16_pcix , 0xf1ff, 0x90fb, { 18, 18, 9, 9}}, - {m68k_op_suba_16_i , 0xf1ff, 0x90fc, { 12, 12, 4, 4}}, - {m68k_op_subx_8_mm_ay7 , 0xf1ff, 0x910f, { 18, 18, 12, 12}}, - {m68k_op_sub_8_re_pi7 , 0xf1ff, 0x911f, { 12, 12, 8, 8}}, - {m68k_op_sub_8_re_pd7 , 0xf1ff, 0x9127, { 14, 14, 9, 9}}, - {m68k_op_sub_8_re_aw , 0xf1ff, 0x9138, { 16, 16, 8, 8}}, - {m68k_op_sub_8_re_al , 0xf1ff, 0x9139, { 20, 20, 8, 8}}, - {m68k_op_sub_16_re_aw , 0xf1ff, 0x9178, { 16, 16, 8, 8}}, - {m68k_op_sub_16_re_al , 0xf1ff, 0x9179, { 20, 20, 8, 8}}, - {m68k_op_sub_32_re_aw , 0xf1ff, 0x91b8, { 24, 24, 8, 8}}, - {m68k_op_sub_32_re_al , 0xf1ff, 0x91b9, { 28, 28, 8, 8}}, - {m68k_op_suba_32_aw , 0xf1ff, 0x91f8, { 18, 18, 6, 6}}, - {m68k_op_suba_32_al , 0xf1ff, 0x91f9, { 22, 22, 6, 6}}, - {m68k_op_suba_32_pcdi , 0xf1ff, 0x91fa, { 18, 18, 7, 7}}, - {m68k_op_suba_32_pcix , 0xf1ff, 0x91fb, { 20, 20, 9, 9}}, - {m68k_op_suba_32_i , 0xf1ff, 0x91fc, { 16, 14, 6, 6}}, - {m68k_op_cmp_8_pi7 , 0xf1ff, 0xb01f, { 8, 8, 6, 6}}, - {m68k_op_cmp_8_pd7 , 0xf1ff, 0xb027, { 10, 10, 7, 7}}, - {m68k_op_cmp_8_aw , 0xf1ff, 0xb038, { 12, 12, 6, 6}}, - {m68k_op_cmp_8_al , 0xf1ff, 0xb039, { 16, 16, 6, 6}}, - {m68k_op_cmp_8_pcdi , 0xf1ff, 0xb03a, { 12, 12, 7, 7}}, - {m68k_op_cmp_8_pcix , 0xf1ff, 0xb03b, { 14, 14, 9, 9}}, - {m68k_op_cmp_8_i , 0xf1ff, 0xb03c, { 8, 8, 4, 4}}, - {m68k_op_cmp_16_aw , 0xf1ff, 0xb078, { 12, 12, 6, 6}}, - {m68k_op_cmp_16_al , 0xf1ff, 0xb079, { 16, 16, 6, 6}}, - {m68k_op_cmp_16_pcdi , 0xf1ff, 0xb07a, { 12, 12, 7, 7}}, - {m68k_op_cmp_16_pcix , 0xf1ff, 0xb07b, { 14, 14, 9, 9}}, - {m68k_op_cmp_16_i , 0xf1ff, 0xb07c, { 8, 8, 4, 4}}, - {m68k_op_cmp_32_aw , 0xf1ff, 0xb0b8, { 18, 18, 6, 6}}, - {m68k_op_cmp_32_al , 0xf1ff, 0xb0b9, { 22, 22, 6, 6}}, - {m68k_op_cmp_32_pcdi , 0xf1ff, 0xb0ba, { 18, 18, 7, 7}}, - {m68k_op_cmp_32_pcix , 0xf1ff, 0xb0bb, { 20, 20, 9, 9}}, - {m68k_op_cmp_32_i , 0xf1ff, 0xb0bc, { 14, 14, 6, 6}}, - {m68k_op_cmpa_16_aw , 0xf1ff, 0xb0f8, { 14, 14, 8, 8}}, - {m68k_op_cmpa_16_al , 0xf1ff, 0xb0f9, { 18, 18, 8, 8}}, - {m68k_op_cmpa_16_pcdi , 0xf1ff, 0xb0fa, { 14, 14, 9, 9}}, - {m68k_op_cmpa_16_pcix , 0xf1ff, 0xb0fb, { 16, 16, 11, 11}}, - {m68k_op_cmpa_16_i , 0xf1ff, 0xb0fc, { 10, 10, 6, 6}}, - {m68k_op_cmpm_8_ay7 , 0xf1ff, 0xb10f, { 12, 12, 9, 9}}, - {m68k_op_eor_8_pi7 , 0xf1ff, 0xb11f, { 12, 12, 8, 8}}, - {m68k_op_eor_8_pd7 , 0xf1ff, 0xb127, { 14, 14, 9, 9}}, - {m68k_op_eor_8_aw , 0xf1ff, 0xb138, { 16, 16, 8, 8}}, - {m68k_op_eor_8_al , 0xf1ff, 0xb139, { 20, 20, 8, 8}}, - {m68k_op_eor_16_aw , 0xf1ff, 0xb178, { 16, 16, 8, 8}}, - {m68k_op_eor_16_al , 0xf1ff, 0xb179, { 20, 20, 8, 8}}, - {m68k_op_eor_32_aw , 0xf1ff, 0xb1b8, { 24, 24, 8, 8}}, - {m68k_op_eor_32_al , 0xf1ff, 0xb1b9, { 28, 28, 8, 8}}, - {m68k_op_cmpa_32_aw , 0xf1ff, 0xb1f8, { 18, 18, 8, 8}}, - {m68k_op_cmpa_32_al , 0xf1ff, 0xb1f9, { 22, 22, 8, 8}}, - {m68k_op_cmpa_32_pcdi , 0xf1ff, 0xb1fa, { 18, 18, 9, 9}}, - {m68k_op_cmpa_32_pcix , 0xf1ff, 0xb1fb, { 20, 20, 11, 11}}, - {m68k_op_cmpa_32_i , 0xf1ff, 0xb1fc, { 14, 14, 8, 8}}, - {m68k_op_and_8_er_pi7 , 0xf1ff, 0xc01f, { 8, 8, 6, 6}}, - {m68k_op_and_8_er_pd7 , 0xf1ff, 0xc027, { 10, 10, 7, 7}}, - {m68k_op_and_8_er_aw , 0xf1ff, 0xc038, { 12, 12, 6, 6}}, - {m68k_op_and_8_er_al , 0xf1ff, 0xc039, { 16, 16, 6, 6}}, - {m68k_op_and_8_er_pcdi , 0xf1ff, 0xc03a, { 12, 12, 7, 7}}, - {m68k_op_and_8_er_pcix , 0xf1ff, 0xc03b, { 14, 14, 9, 9}}, - {m68k_op_and_8_er_i , 0xf1ff, 0xc03c, { 8, 8, 4, 4}}, - {m68k_op_and_16_er_aw , 0xf1ff, 0xc078, { 12, 12, 6, 6}}, - {m68k_op_and_16_er_al , 0xf1ff, 0xc079, { 16, 16, 6, 6}}, - {m68k_op_and_16_er_pcdi , 0xf1ff, 0xc07a, { 12, 12, 7, 7}}, - {m68k_op_and_16_er_pcix , 0xf1ff, 0xc07b, { 14, 14, 9, 9}}, - {m68k_op_and_16_er_i , 0xf1ff, 0xc07c, { 8, 8, 4, 4}}, - {m68k_op_and_32_er_aw , 0xf1ff, 0xc0b8, { 18, 18, 6, 6}}, - {m68k_op_and_32_er_al , 0xf1ff, 0xc0b9, { 22, 22, 6, 6}}, - {m68k_op_and_32_er_pcdi , 0xf1ff, 0xc0ba, { 18, 18, 7, 7}}, - {m68k_op_and_32_er_pcix , 0xf1ff, 0xc0bb, { 20, 20, 9, 9}}, - {m68k_op_and_32_er_i , 0xf1ff, 0xc0bc, { 16, 14, 6, 6}}, - {m68k_op_mulu_16_aw , 0xf1ff, 0xc0f8, { 8, 38, 31, 31}}, - {m68k_op_mulu_16_al , 0xf1ff, 0xc0f9, { 12, 42, 31, 31}}, - {m68k_op_mulu_16_pcdi , 0xf1ff, 0xc0fa, { 8, 38, 32, 32}}, - {m68k_op_mulu_16_pcix , 0xf1ff, 0xc0fb, { 10, 40, 34, 34}}, - {m68k_op_mulu_16_i , 0xf1ff, 0xc0fc, { 4, 34, 29, 29}}, - {m68k_op_abcd_8_mm_ay7 , 0xf1ff, 0xc10f, { 18, 18, 16, 16}}, - {m68k_op_and_8_re_pi7 , 0xf1ff, 0xc11f, { 12, 12, 8, 8}}, - {m68k_op_and_8_re_pd7 , 0xf1ff, 0xc127, { 14, 14, 9, 9}}, - {m68k_op_and_8_re_aw , 0xf1ff, 0xc138, { 16, 16, 8, 8}}, - {m68k_op_and_8_re_al , 0xf1ff, 0xc139, { 20, 20, 8, 8}}, - {m68k_op_and_16_re_aw , 0xf1ff, 0xc178, { 16, 16, 8, 8}}, - {m68k_op_and_16_re_al , 0xf1ff, 0xc179, { 20, 20, 8, 8}}, - {m68k_op_and_32_re_aw , 0xf1ff, 0xc1b8, { 24, 24, 8, 8}}, - {m68k_op_and_32_re_al , 0xf1ff, 0xc1b9, { 28, 28, 8, 8}}, - {m68k_op_muls_16_aw , 0xf1ff, 0xc1f8, { 8, 40, 31, 31}}, - {m68k_op_muls_16_al , 0xf1ff, 0xc1f9, { 12, 44, 31, 31}}, - {m68k_op_muls_16_pcdi , 0xf1ff, 0xc1fa, { 8, 40, 32, 32}}, - {m68k_op_muls_16_pcix , 0xf1ff, 0xc1fb, { 10, 42, 34, 34}}, - {m68k_op_muls_16_i , 0xf1ff, 0xc1fc, { 4, 36, 29, 29}}, - {m68k_op_add_8_er_pi7 , 0xf1ff, 0xd01f, { 8, 8, 6, 6}}, - {m68k_op_add_8_er_pd7 , 0xf1ff, 0xd027, { 10, 10, 7, 7}}, - {m68k_op_add_8_er_aw , 0xf1ff, 0xd038, { 12, 12, 6, 6}}, - {m68k_op_add_8_er_al , 0xf1ff, 0xd039, { 16, 16, 6, 6}}, - {m68k_op_add_8_er_pcdi , 0xf1ff, 0xd03a, { 12, 12, 7, 7}}, - {m68k_op_add_8_er_pcix , 0xf1ff, 0xd03b, { 14, 14, 9, 9}}, - {m68k_op_add_8_er_i , 0xf1ff, 0xd03c, { 8, 8, 4, 4}}, - {m68k_op_add_16_er_aw , 0xf1ff, 0xd078, { 12, 12, 6, 6}}, - {m68k_op_add_16_er_al , 0xf1ff, 0xd079, { 16, 16, 6, 6}}, - {m68k_op_add_16_er_pcdi , 0xf1ff, 0xd07a, { 12, 12, 7, 7}}, - {m68k_op_add_16_er_pcix , 0xf1ff, 0xd07b, { 14, 14, 9, 9}}, - {m68k_op_add_16_er_i , 0xf1ff, 0xd07c, { 8, 8, 4, 4}}, - {m68k_op_add_32_er_aw , 0xf1ff, 0xd0b8, { 18, 18, 6, 6}}, - {m68k_op_add_32_er_al , 0xf1ff, 0xd0b9, { 22, 22, 6, 6}}, - {m68k_op_add_32_er_pcdi , 0xf1ff, 0xd0ba, { 18, 18, 7, 7}}, - {m68k_op_add_32_er_pcix , 0xf1ff, 0xd0bb, { 20, 20, 9, 9}}, - {m68k_op_add_32_er_i , 0xf1ff, 0xd0bc, { 16, 14, 6, 6}}, - {m68k_op_adda_16_aw , 0xf1ff, 0xd0f8, { 16, 16, 6, 6}}, - {m68k_op_adda_16_al , 0xf1ff, 0xd0f9, { 20, 20, 6, 6}}, - {m68k_op_adda_16_pcdi , 0xf1ff, 0xd0fa, { 16, 16, 7, 7}}, - {m68k_op_adda_16_pcix , 0xf1ff, 0xd0fb, { 18, 18, 9, 9}}, - {m68k_op_adda_16_i , 0xf1ff, 0xd0fc, { 12, 12, 4, 4}}, - {m68k_op_addx_8_mm_ay7 , 0xf1ff, 0xd10f, { 18, 18, 12, 12}}, - {m68k_op_add_8_re_pi7 , 0xf1ff, 0xd11f, { 12, 12, 8, 8}}, - {m68k_op_add_8_re_pd7 , 0xf1ff, 0xd127, { 14, 14, 9, 9}}, - {m68k_op_add_8_re_aw , 0xf1ff, 0xd138, { 16, 16, 8, 8}}, - {m68k_op_add_8_re_al , 0xf1ff, 0xd139, { 20, 20, 8, 8}}, - {m68k_op_add_16_re_aw , 0xf1ff, 0xd178, { 16, 16, 8, 8}}, - {m68k_op_add_16_re_al , 0xf1ff, 0xd179, { 20, 20, 8, 8}}, - {m68k_op_add_32_re_aw , 0xf1ff, 0xd1b8, { 24, 24, 8, 8}}, - {m68k_op_add_32_re_al , 0xf1ff, 0xd1b9, { 28, 28, 8, 8}}, - {m68k_op_adda_32_aw , 0xf1ff, 0xd1f8, { 18, 18, 6, 6}}, - {m68k_op_adda_32_al , 0xf1ff, 0xd1f9, { 22, 22, 6, 6}}, - {m68k_op_adda_32_pcdi , 0xf1ff, 0xd1fa, { 18, 18, 7, 7}}, - {m68k_op_adda_32_pcix , 0xf1ff, 0xd1fb, { 20, 20, 9, 9}}, - {m68k_op_adda_32_i , 0xf1ff, 0xd1fc, { 16, 14, 6, 6}}, - {m68k_op_ori_8_d , 0xfff8, 0x0000, { 8, 8, 2, 2}}, - {m68k_op_ori_8_ai , 0xfff8, 0x0010, { 16, 16, 8, 8}}, - {m68k_op_ori_8_pi , 0xfff8, 0x0018, { 16, 16, 8, 8}}, - {m68k_op_ori_8_pd , 0xfff8, 0x0020, { 18, 18, 9, 9}}, - {m68k_op_ori_8_di , 0xfff8, 0x0028, { 20, 20, 9, 9}}, - {m68k_op_ori_8_ix , 0xfff8, 0x0030, { 22, 22, 11, 11}}, - {m68k_op_ori_16_d , 0xfff8, 0x0040, { 8, 8, 2, 2}}, - {m68k_op_ori_16_ai , 0xfff8, 0x0050, { 16, 16, 8, 8}}, - {m68k_op_ori_16_pi , 0xfff8, 0x0058, { 16, 16, 8, 8}}, - {m68k_op_ori_16_pd , 0xfff8, 0x0060, { 18, 18, 9, 9}}, - {m68k_op_ori_16_di , 0xfff8, 0x0068, { 20, 20, 9, 9}}, - {m68k_op_ori_16_ix , 0xfff8, 0x0070, { 22, 22, 11, 11}}, - {m68k_op_ori_32_d , 0xfff8, 0x0080, { 16, 14, 2, 2}}, - {m68k_op_ori_32_ai , 0xfff8, 0x0090, { 28, 28, 8, 8}}, - {m68k_op_ori_32_pi , 0xfff8, 0x0098, { 28, 28, 8, 8}}, - {m68k_op_ori_32_pd , 0xfff8, 0x00a0, { 30, 30, 9, 9}}, - {m68k_op_ori_32_di , 0xfff8, 0x00a8, { 32, 32, 9, 9}}, - {m68k_op_ori_32_ix , 0xfff8, 0x00b0, { 34, 34, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_chk2cmp2_8_ai , 0xfff8, 0x00d0, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_8_di , 0xfff8, 0x00e8, { 0, 0, 23, 23}}, - {m68k_op_chk2cmp2_8_ix , 0xfff8, 0x00f0, { 0, 0, 25, 25}}, -#endif - {m68k_op_andi_8_d , 0xfff8, 0x0200, { 8, 8, 2, 2}}, - {m68k_op_andi_8_ai , 0xfff8, 0x0210, { 16, 16, 8, 8}}, - {m68k_op_andi_8_pi , 0xfff8, 0x0218, { 16, 16, 8, 8}}, - {m68k_op_andi_8_pd , 0xfff8, 0x0220, { 18, 18, 9, 9}}, - {m68k_op_andi_8_di , 0xfff8, 0x0228, { 20, 20, 9, 9}}, - {m68k_op_andi_8_ix , 0xfff8, 0x0230, { 22, 22, 11, 11}}, - {m68k_op_andi_16_d , 0xfff8, 0x0240, { 8, 8, 2, 2}}, - {m68k_op_andi_16_ai , 0xfff8, 0x0250, { 16, 16, 8, 8}}, - {m68k_op_andi_16_pi , 0xfff8, 0x0258, { 16, 16, 8, 8}}, - {m68k_op_andi_16_pd , 0xfff8, 0x0260, { 18, 18, 9, 9}}, - {m68k_op_andi_16_di , 0xfff8, 0x0268, { 20, 20, 9, 9}}, - {m68k_op_andi_16_ix , 0xfff8, 0x0270, { 22, 22, 11, 11}}, - {m68k_op_andi_32_d , 0xfff8, 0x0280, { 14, 14, 2, 2}}, - {m68k_op_andi_32_ai , 0xfff8, 0x0290, { 28, 28, 8, 8}}, - {m68k_op_andi_32_pi , 0xfff8, 0x0298, { 28, 28, 8, 8}}, - {m68k_op_andi_32_pd , 0xfff8, 0x02a0, { 30, 30, 9, 9}}, - {m68k_op_andi_32_di , 0xfff8, 0x02a8, { 32, 32, 9, 9}}, - {m68k_op_andi_32_ix , 0xfff8, 0x02b0, { 34, 34, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_chk2cmp2_16_ai , 0xfff8, 0x02d0, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_16_di , 0xfff8, 0x02e8, { 0, 0, 23, 23}}, - {m68k_op_chk2cmp2_16_ix , 0xfff8, 0x02f0, { 0, 0, 25, 25}}, -#endif - {m68k_op_subi_8_d , 0xfff8, 0x0400, { 8, 8, 2, 2}}, - {m68k_op_subi_8_ai , 0xfff8, 0x0410, { 16, 16, 8, 8}}, - {m68k_op_subi_8_pi , 0xfff8, 0x0418, { 16, 16, 8, 8}}, - {m68k_op_subi_8_pd , 0xfff8, 0x0420, { 18, 18, 9, 9}}, - {m68k_op_subi_8_di , 0xfff8, 0x0428, { 20, 20, 9, 9}}, - {m68k_op_subi_8_ix , 0xfff8, 0x0430, { 22, 22, 11, 11}}, - {m68k_op_subi_16_d , 0xfff8, 0x0440, { 8, 8, 2, 2}}, - {m68k_op_subi_16_ai , 0xfff8, 0x0450, { 16, 16, 8, 8}}, - {m68k_op_subi_16_pi , 0xfff8, 0x0458, { 16, 16, 8, 8}}, - {m68k_op_subi_16_pd , 0xfff8, 0x0460, { 18, 18, 9, 9}}, - {m68k_op_subi_16_di , 0xfff8, 0x0468, { 20, 20, 9, 9}}, - {m68k_op_subi_16_ix , 0xfff8, 0x0470, { 22, 22, 11, 11}}, - {m68k_op_subi_32_d , 0xfff8, 0x0480, { 16, 14, 2, 2}}, - {m68k_op_subi_32_ai , 0xfff8, 0x0490, { 28, 28, 8, 8}}, - {m68k_op_subi_32_pi , 0xfff8, 0x0498, { 28, 28, 8, 8}}, - {m68k_op_subi_32_pd , 0xfff8, 0x04a0, { 30, 30, 9, 9}}, - {m68k_op_subi_32_di , 0xfff8, 0x04a8, { 32, 32, 9, 9}}, - {m68k_op_subi_32_ix , 0xfff8, 0x04b0, { 34, 34, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_chk2cmp2_32_ai , 0xfff8, 0x04d0, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_32_di , 0xfff8, 0x04e8, { 0, 0, 23, 23}}, - {m68k_op_chk2cmp2_32_ix , 0xfff8, 0x04f0, { 0, 0, 25, 25}}, -#endif - {m68k_op_addi_8_d , 0xfff8, 0x0600, { 8, 8, 2, 2}}, - {m68k_op_addi_8_ai , 0xfff8, 0x0610, { 16, 16, 8, 8}}, - {m68k_op_addi_8_pi , 0xfff8, 0x0618, { 16, 16, 8, 8}}, - {m68k_op_addi_8_pd , 0xfff8, 0x0620, { 18, 18, 9, 9}}, - {m68k_op_addi_8_di , 0xfff8, 0x0628, { 20, 20, 9, 9}}, - {m68k_op_addi_8_ix , 0xfff8, 0x0630, { 22, 22, 11, 11}}, - {m68k_op_addi_16_d , 0xfff8, 0x0640, { 8, 8, 2, 2}}, - {m68k_op_addi_16_ai , 0xfff8, 0x0650, { 16, 16, 8, 8}}, - {m68k_op_addi_16_pi , 0xfff8, 0x0658, { 16, 16, 8, 8}}, - {m68k_op_addi_16_pd , 0xfff8, 0x0660, { 18, 18, 9, 9}}, - {m68k_op_addi_16_di , 0xfff8, 0x0668, { 20, 20, 9, 9}}, - {m68k_op_addi_16_ix , 0xfff8, 0x0670, { 22, 22, 11, 11}}, - {m68k_op_addi_32_d , 0xfff8, 0x0680, { 16, 14, 2, 2}}, - {m68k_op_addi_32_ai , 0xfff8, 0x0690, { 28, 28, 8, 8}}, - {m68k_op_addi_32_pi , 0xfff8, 0x0698, { 28, 28, 8, 8}}, - {m68k_op_addi_32_pd , 0xfff8, 0x06a0, { 30, 30, 9, 9}}, - {m68k_op_addi_32_di , 0xfff8, 0x06a8, { 32, 32, 9, 9}}, - {m68k_op_addi_32_ix , 0xfff8, 0x06b0, { 34, 34, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_callm_32_ai , 0xfff8, 0x06d0, { 0, 0, 64, 64}}, - {m68k_op_callm_32_di , 0xfff8, 0x06e8, { 0, 0, 65, 65}}, - {m68k_op_callm_32_ix , 0xfff8, 0x06f0, { 0, 0, 67, 67}}, -#endif - {m68k_op_btst_32_s_d , 0xfff8, 0x0800, { 10, 10, 4, 4}}, - {m68k_op_btst_8_s_ai , 0xfff8, 0x0810, { 12, 12, 8, 8}}, - {m68k_op_btst_8_s_pi , 0xfff8, 0x0818, { 12, 12, 8, 8}}, - {m68k_op_btst_8_s_pd , 0xfff8, 0x0820, { 14, 14, 9, 9}}, - {m68k_op_btst_8_s_di , 0xfff8, 0x0828, { 16, 16, 9, 9}}, - {m68k_op_btst_8_s_ix , 0xfff8, 0x0830, { 18, 18, 11, 11}}, - {m68k_op_bchg_32_s_d , 0xfff8, 0x0840, { 12, 12, 4, 4}}, - {m68k_op_bchg_8_s_ai , 0xfff8, 0x0850, { 16, 16, 8, 8}}, - {m68k_op_bchg_8_s_pi , 0xfff8, 0x0858, { 16, 16, 8, 8}}, - {m68k_op_bchg_8_s_pd , 0xfff8, 0x0860, { 18, 18, 9, 9}}, - {m68k_op_bchg_8_s_di , 0xfff8, 0x0868, { 20, 20, 9, 9}}, - {m68k_op_bchg_8_s_ix , 0xfff8, 0x0870, { 22, 22, 11, 11}}, - {m68k_op_bclr_32_s_d , 0xfff8, 0x0880, { 14, 14, 4, 4}}, - {m68k_op_bclr_8_s_ai , 0xfff8, 0x0890, { 16, 16, 8, 8}}, - {m68k_op_bclr_8_s_pi , 0xfff8, 0x0898, { 16, 16, 8, 8}}, - {m68k_op_bclr_8_s_pd , 0xfff8, 0x08a0, { 18, 18, 9, 9}}, - {m68k_op_bclr_8_s_di , 0xfff8, 0x08a8, { 20, 20, 9, 9}}, - {m68k_op_bclr_8_s_ix , 0xfff8, 0x08b0, { 22, 22, 11, 11}}, - {m68k_op_bset_32_s_d , 0xfff8, 0x08c0, { 12, 12, 4, 4}}, - {m68k_op_bset_8_s_ai , 0xfff8, 0x08d0, { 16, 16, 8, 8}}, - {m68k_op_bset_8_s_pi , 0xfff8, 0x08d8, { 16, 16, 8, 8}}, - {m68k_op_bset_8_s_pd , 0xfff8, 0x08e0, { 18, 18, 9, 9}}, - {m68k_op_bset_8_s_di , 0xfff8, 0x08e8, { 20, 20, 9, 9}}, - {m68k_op_bset_8_s_ix , 0xfff8, 0x08f0, { 22, 22, 11, 11}}, - {m68k_op_eori_8_d , 0xfff8, 0x0a00, { 8, 8, 2, 2}}, - {m68k_op_eori_8_ai , 0xfff8, 0x0a10, { 16, 16, 8, 8}}, - {m68k_op_eori_8_pi , 0xfff8, 0x0a18, { 16, 16, 8, 8}}, - {m68k_op_eori_8_pd , 0xfff8, 0x0a20, { 18, 18, 9, 9}}, - {m68k_op_eori_8_di , 0xfff8, 0x0a28, { 20, 20, 9, 9}}, - {m68k_op_eori_8_ix , 0xfff8, 0x0a30, { 22, 22, 11, 11}}, - {m68k_op_eori_16_d , 0xfff8, 0x0a40, { 8, 8, 2, 2}}, - {m68k_op_eori_16_ai , 0xfff8, 0x0a50, { 16, 16, 8, 8}}, - {m68k_op_eori_16_pi , 0xfff8, 0x0a58, { 16, 16, 8, 8}}, - {m68k_op_eori_16_pd , 0xfff8, 0x0a60, { 18, 18, 9, 9}}, - {m68k_op_eori_16_di , 0xfff8, 0x0a68, { 20, 20, 9, 9}}, - {m68k_op_eori_16_ix , 0xfff8, 0x0a70, { 22, 22, 11, 11}}, - {m68k_op_eori_32_d , 0xfff8, 0x0a80, { 16, 14, 2, 2}}, - {m68k_op_eori_32_ai , 0xfff8, 0x0a90, { 28, 28, 8, 8}}, - {m68k_op_eori_32_pi , 0xfff8, 0x0a98, { 28, 28, 8, 8}}, - {m68k_op_eori_32_pd , 0xfff8, 0x0aa0, { 30, 30, 9, 9}}, - {m68k_op_eori_32_di , 0xfff8, 0x0aa8, { 32, 32, 9, 9}}, - {m68k_op_eori_32_ix , 0xfff8, 0x0ab0, { 34, 34, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cas_8_ai , 0xfff8, 0x0ad0, { 0, 0, 16, 16}}, - {m68k_op_cas_8_pi , 0xfff8, 0x0ad8, { 0, 0, 16, 16}}, - {m68k_op_cas_8_pd , 0xfff8, 0x0ae0, { 0, 0, 17, 17}}, - {m68k_op_cas_8_di , 0xfff8, 0x0ae8, { 0, 0, 17, 17}}, - {m68k_op_cas_8_ix , 0xfff8, 0x0af0, { 0, 0, 19, 19}}, -#endif - {m68k_op_cmpi_8_d , 0xfff8, 0x0c00, { 8, 8, 2, 2}}, - {m68k_op_cmpi_8_ai , 0xfff8, 0x0c10, { 12, 12, 6, 6}}, - {m68k_op_cmpi_8_pi , 0xfff8, 0x0c18, { 12, 12, 6, 6}}, - {m68k_op_cmpi_8_pd , 0xfff8, 0x0c20, { 14, 14, 7, 7}}, - {m68k_op_cmpi_8_di , 0xfff8, 0x0c28, { 16, 16, 7, 7}}, - {m68k_op_cmpi_8_ix , 0xfff8, 0x0c30, { 18, 18, 9, 9}}, - {m68k_op_cmpi_16_d , 0xfff8, 0x0c40, { 8, 8, 2, 2}}, - {m68k_op_cmpi_16_ai , 0xfff8, 0x0c50, { 12, 12, 6, 6}}, - {m68k_op_cmpi_16_pi , 0xfff8, 0x0c58, { 12, 12, 6, 6}}, - {m68k_op_cmpi_16_pd , 0xfff8, 0x0c60, { 14, 14, 7, 7}}, - {m68k_op_cmpi_16_di , 0xfff8, 0x0c68, { 16, 16, 7, 7}}, - {m68k_op_cmpi_16_ix , 0xfff8, 0x0c70, { 18, 18, 9, 9}}, - {m68k_op_cmpi_32_d , 0xfff8, 0x0c80, { 14, 12, 2, 2}}, - {m68k_op_cmpi_32_ai , 0xfff8, 0x0c90, { 20, 20, 6, 6}}, - {m68k_op_cmpi_32_pi , 0xfff8, 0x0c98, { 20, 20, 6, 6}}, - {m68k_op_cmpi_32_pd , 0xfff8, 0x0ca0, { 22, 22, 7, 7}}, - {m68k_op_cmpi_32_di , 0xfff8, 0x0ca8, { 24, 24, 7, 7}}, - {m68k_op_cmpi_32_ix , 0xfff8, 0x0cb0, { 26, 26, 9, 9}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cas_16_ai , 0xfff8, 0x0cd0, { 0, 0, 16, 16}}, - {m68k_op_cas_16_pi , 0xfff8, 0x0cd8, { 0, 0, 16, 16}}, - {m68k_op_cas_16_pd , 0xfff8, 0x0ce0, { 0, 0, 17, 17}}, - {m68k_op_cas_16_di , 0xfff8, 0x0ce8, { 0, 0, 17, 17}}, - {m68k_op_cas_16_ix , 0xfff8, 0x0cf0, { 0, 0, 19, 19}}, -#endif -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_moves_8_ai , 0xfff8, 0x0e10, { 0, 18, 9, 9}}, - {m68k_op_moves_8_pi , 0xfff8, 0x0e18, { 0, 18, 9, 9}}, - {m68k_op_moves_8_pd , 0xfff8, 0x0e20, { 0, 20, 10, 10}}, - {m68k_op_moves_8_di , 0xfff8, 0x0e28, { 0, 26, 10, 10}}, - {m68k_op_moves_8_ix , 0xfff8, 0x0e30, { 0, 30, 12, 12}}, - {m68k_op_moves_16_ai , 0xfff8, 0x0e50, { 0, 18, 9, 9}}, - {m68k_op_moves_16_pi , 0xfff8, 0x0e58, { 0, 18, 9, 9}}, - {m68k_op_moves_16_pd , 0xfff8, 0x0e60, { 0, 20, 10, 10}}, - {m68k_op_moves_16_di , 0xfff8, 0x0e68, { 0, 26, 10, 10}}, - {m68k_op_moves_16_ix , 0xfff8, 0x0e70, { 0, 30, 12, 12}}, - {m68k_op_moves_32_ai , 0xfff8, 0x0e90, { 0, 22, 9, 9}}, - {m68k_op_moves_32_pi , 0xfff8, 0x0e98, { 0, 22, 9, 9}}, - {m68k_op_moves_32_pd , 0xfff8, 0x0ea0, { 0, 28, 10, 10}}, - {m68k_op_moves_32_di , 0xfff8, 0x0ea8, { 0, 32, 10, 10}}, - {m68k_op_moves_32_ix , 0xfff8, 0x0eb0, { 0, 36, 12, 12}}, -#endif -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cas_32_ai , 0xfff8, 0x0ed0, { 0, 0, 16, 16}}, - {m68k_op_cas_32_pi , 0xfff8, 0x0ed8, { 0, 0, 16, 16}}, - {m68k_op_cas_32_pd , 0xfff8, 0x0ee0, { 0, 0, 17, 17}}, - {m68k_op_cas_32_di , 0xfff8, 0x0ee8, { 0, 0, 17, 17}}, - {m68k_op_cas_32_ix , 0xfff8, 0x0ef0, { 0, 0, 19, 19}}, -#endif - {m68k_op_move_8_aw_d , 0xfff8, 0x11c0, { 12, 12, 4, 4}}, - {m68k_op_move_8_aw_ai , 0xfff8, 0x11d0, { 16, 16, 8, 8}}, - {m68k_op_move_8_aw_pi , 0xfff8, 0x11d8, { 16, 16, 8, 8}}, - {m68k_op_move_8_aw_pd , 0xfff8, 0x11e0, { 18, 18, 9, 9}}, - {m68k_op_move_8_aw_di , 0xfff8, 0x11e8, { 20, 20, 9, 9}}, - {m68k_op_move_8_aw_ix , 0xfff8, 0x11f0, { 22, 22, 11, 11}}, - {m68k_op_move_8_al_d , 0xfff8, 0x13c0, { 16, 16, 6, 6}}, - {m68k_op_move_8_al_ai , 0xfff8, 0x13d0, { 20, 20, 10, 10}}, - {m68k_op_move_8_al_pi , 0xfff8, 0x13d8, { 20, 20, 10, 10}}, - {m68k_op_move_8_al_pd , 0xfff8, 0x13e0, { 22, 22, 11, 11}}, - {m68k_op_move_8_al_di , 0xfff8, 0x13e8, { 24, 24, 11, 11}}, - {m68k_op_move_8_al_ix , 0xfff8, 0x13f0, { 26, 26, 13, 13}}, - {m68k_op_move_8_pi7_d , 0xfff8, 0x1ec0, { 8, 8, 4, 4}}, - {m68k_op_move_8_pi7_ai , 0xfff8, 0x1ed0, { 12, 12, 8, 8}}, - {m68k_op_move_8_pi7_pi , 0xfff8, 0x1ed8, { 12, 12, 8, 8}}, - {m68k_op_move_8_pi7_pd , 0xfff8, 0x1ee0, { 14, 14, 9, 9}}, - {m68k_op_move_8_pi7_di , 0xfff8, 0x1ee8, { 16, 16, 9, 9}}, - {m68k_op_move_8_pi7_ix , 0xfff8, 0x1ef0, { 18, 18, 11, 11}}, - {m68k_op_move_8_pd7_d , 0xfff8, 0x1f00, { 8, 8, 5, 5}}, - {m68k_op_move_8_pd7_ai , 0xfff8, 0x1f10, { 12, 12, 9, 9}}, - {m68k_op_move_8_pd7_pi , 0xfff8, 0x1f18, { 12, 12, 9, 9}}, - {m68k_op_move_8_pd7_pd , 0xfff8, 0x1f20, { 14, 14, 10, 10}}, - {m68k_op_move_8_pd7_di , 0xfff8, 0x1f28, { 16, 16, 10, 10}}, - {m68k_op_move_8_pd7_ix , 0xfff8, 0x1f30, { 18, 18, 12, 12}}, - {m68k_op_move_32_aw_d , 0xfff8, 0x21c0, { 16, 16, 4, 4}}, - {m68k_op_move_32_aw_a , 0xfff8, 0x21c8, { 16, 16, 4, 4}}, - {m68k_op_move_32_aw_ai , 0xfff8, 0x21d0, { 24, 24, 8, 8}}, - {m68k_op_move_32_aw_pi , 0xfff8, 0x21d8, { 24, 24, 8, 8}}, - {m68k_op_move_32_aw_pd , 0xfff8, 0x21e0, { 26, 26, 9, 9}}, - {m68k_op_move_32_aw_di , 0xfff8, 0x21e8, { 28, 28, 9, 9}}, - {m68k_op_move_32_aw_ix , 0xfff8, 0x21f0, { 30, 30, 11, 11}}, - {m68k_op_move_32_al_d , 0xfff8, 0x23c0, { 20, 20, 6, 6}}, - {m68k_op_move_32_al_a , 0xfff8, 0x23c8, { 20, 20, 6, 6}}, - {m68k_op_move_32_al_ai , 0xfff8, 0x23d0, { 28, 28, 10, 10}}, - {m68k_op_move_32_al_pi , 0xfff8, 0x23d8, { 28, 28, 10, 10}}, - {m68k_op_move_32_al_pd , 0xfff8, 0x23e0, { 30, 30, 11, 11}}, - {m68k_op_move_32_al_di , 0xfff8, 0x23e8, { 32, 32, 11, 11}}, - {m68k_op_move_32_al_ix , 0xfff8, 0x23f0, { 34, 34, 13, 13}}, - {m68k_op_move_16_aw_d , 0xfff8, 0x31c0, { 12, 12, 4, 4}}, - {m68k_op_move_16_aw_a , 0xfff8, 0x31c8, { 12, 12, 4, 4}}, - {m68k_op_move_16_aw_ai , 0xfff8, 0x31d0, { 16, 16, 8, 8}}, - {m68k_op_move_16_aw_pi , 0xfff8, 0x31d8, { 16, 16, 8, 8}}, - {m68k_op_move_16_aw_pd , 0xfff8, 0x31e0, { 18, 18, 9, 9}}, - {m68k_op_move_16_aw_di , 0xfff8, 0x31e8, { 20, 20, 9, 9}}, - {m68k_op_move_16_aw_ix , 0xfff8, 0x31f0, { 22, 22, 11, 11}}, - {m68k_op_move_16_al_d , 0xfff8, 0x33c0, { 16, 16, 6, 6}}, - {m68k_op_move_16_al_a , 0xfff8, 0x33c8, { 16, 16, 6, 6}}, - {m68k_op_move_16_al_ai , 0xfff8, 0x33d0, { 20, 20, 10, 10}}, - {m68k_op_move_16_al_pi , 0xfff8, 0x33d8, { 20, 20, 10, 10}}, - {m68k_op_move_16_al_pd , 0xfff8, 0x33e0, { 22, 22, 11, 11}}, - {m68k_op_move_16_al_di , 0xfff8, 0x33e8, { 24, 24, 11, 11}}, - {m68k_op_move_16_al_ix , 0xfff8, 0x33f0, { 26, 26, 13, 13}}, - {m68k_op_negx_8_d , 0xfff8, 0x4000, { 4, 4, 2, 2}}, - {m68k_op_negx_8_ai , 0xfff8, 0x4010, { 12, 12, 8, 8}}, - {m68k_op_negx_8_pi , 0xfff8, 0x4018, { 12, 12, 8, 8}}, - {m68k_op_negx_8_pd , 0xfff8, 0x4020, { 14, 14, 9, 9}}, - {m68k_op_negx_8_di , 0xfff8, 0x4028, { 16, 16, 9, 9}}, - {m68k_op_negx_8_ix , 0xfff8, 0x4030, { 18, 18, 11, 11}}, - {m68k_op_negx_16_d , 0xfff8, 0x4040, { 4, 4, 2, 2}}, - {m68k_op_negx_16_ai , 0xfff8, 0x4050, { 12, 12, 8, 8}}, - {m68k_op_negx_16_pi , 0xfff8, 0x4058, { 12, 12, 8, 8}}, - {m68k_op_negx_16_pd , 0xfff8, 0x4060, { 14, 14, 9, 9}}, - {m68k_op_negx_16_di , 0xfff8, 0x4068, { 16, 16, 9, 9}}, - {m68k_op_negx_16_ix , 0xfff8, 0x4070, { 18, 18, 11, 11}}, - {m68k_op_negx_32_d , 0xfff8, 0x4080, { 6, 6, 2, 2}}, - {m68k_op_negx_32_ai , 0xfff8, 0x4090, { 20, 20, 8, 8}}, - {m68k_op_negx_32_pi , 0xfff8, 0x4098, { 20, 20, 8, 8}}, - {m68k_op_negx_32_pd , 0xfff8, 0x40a0, { 22, 22, 9, 9}}, - {m68k_op_negx_32_di , 0xfff8, 0x40a8, { 24, 24, 9, 9}}, - {m68k_op_negx_32_ix , 0xfff8, 0x40b0, { 26, 26, 11, 11}}, - {m68k_op_move_16_frs_d , 0xfff8, 0x40c0, { 6, 4, 8, 8}}, - {m68k_op_move_16_frs_ai , 0xfff8, 0x40d0, { 12, 12, 12, 12}}, - {m68k_op_move_16_frs_pi , 0xfff8, 0x40d8, { 12, 12, 12, 12}}, - {m68k_op_move_16_frs_pd , 0xfff8, 0x40e0, { 14, 14, 13, 13}}, - {m68k_op_move_16_frs_di , 0xfff8, 0x40e8, { 16, 16, 13, 13}}, - {m68k_op_move_16_frs_ix , 0xfff8, 0x40f0, { 18, 18, 15, 15}}, - {m68k_op_clr_8_d , 0xfff8, 0x4200, { 4, 4, 2, 2}}, - {m68k_op_clr_8_ai , 0xfff8, 0x4210, { 12, 8, 8, 8}}, - {m68k_op_clr_8_pi , 0xfff8, 0x4218, { 12, 8, 8, 8}}, - {m68k_op_clr_8_pd , 0xfff8, 0x4220, { 14, 10, 9, 9}}, - {m68k_op_clr_8_di , 0xfff8, 0x4228, { 16, 12, 9, 9}}, - {m68k_op_clr_8_ix , 0xfff8, 0x4230, { 18, 14, 11, 11}}, - {m68k_op_clr_16_d , 0xfff8, 0x4240, { 4, 4, 2, 2}}, - {m68k_op_clr_16_ai , 0xfff8, 0x4250, { 12, 8, 8, 8}}, - {m68k_op_clr_16_pi , 0xfff8, 0x4258, { 12, 8, 8, 8}}, - {m68k_op_clr_16_pd , 0xfff8, 0x4260, { 14, 10, 9, 9}}, - {m68k_op_clr_16_di , 0xfff8, 0x4268, { 16, 12, 9, 9}}, - {m68k_op_clr_16_ix , 0xfff8, 0x4270, { 18, 14, 11, 11}}, - {m68k_op_clr_32_d , 0xfff8, 0x4280, { 6, 6, 2, 2}}, - {m68k_op_clr_32_ai , 0xfff8, 0x4290, { 20, 12, 8, 8}}, - {m68k_op_clr_32_pi , 0xfff8, 0x4298, { 20, 12, 8, 8}}, - {m68k_op_clr_32_pd , 0xfff8, 0x42a0, { 22, 14, 9, 9}}, - {m68k_op_clr_32_di , 0xfff8, 0x42a8, { 24, 16, 9, 9}}, - {m68k_op_clr_32_ix , 0xfff8, 0x42b0, { 26, 20, 11, 11}}, -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_move_16_frc_d , 0xfff8, 0x42c0, { 0, 4, 4, 4}}, - {m68k_op_move_16_frc_ai , 0xfff8, 0x42d0, { 0, 12, 8, 8}}, - {m68k_op_move_16_frc_pi , 0xfff8, 0x42d8, { 0, 12, 8, 8}}, - {m68k_op_move_16_frc_pd , 0xfff8, 0x42e0, { 0, 14, 9, 9}}, - {m68k_op_move_16_frc_di , 0xfff8, 0x42e8, { 0, 16, 9, 9}}, - {m68k_op_move_16_frc_ix , 0xfff8, 0x42f0, { 0, 18, 11, 11}}, -#endif - {m68k_op_neg_8_d , 0xfff8, 0x4400, { 4, 4, 2, 2}}, - {m68k_op_neg_8_ai , 0xfff8, 0x4410, { 12, 12, 8, 8}}, - {m68k_op_neg_8_pi , 0xfff8, 0x4418, { 12, 12, 8, 8}}, - {m68k_op_neg_8_pd , 0xfff8, 0x4420, { 14, 14, 9, 9}}, - {m68k_op_neg_8_di , 0xfff8, 0x4428, { 16, 16, 9, 9}}, - {m68k_op_neg_8_ix , 0xfff8, 0x4430, { 18, 18, 11, 11}}, - {m68k_op_neg_16_d , 0xfff8, 0x4440, { 4, 4, 2, 2}}, - {m68k_op_neg_16_ai , 0xfff8, 0x4450, { 12, 12, 8, 8}}, - {m68k_op_neg_16_pi , 0xfff8, 0x4458, { 12, 12, 8, 8}}, - {m68k_op_neg_16_pd , 0xfff8, 0x4460, { 14, 14, 9, 9}}, - {m68k_op_neg_16_di , 0xfff8, 0x4468, { 16, 16, 9, 9}}, - {m68k_op_neg_16_ix , 0xfff8, 0x4470, { 18, 18, 11, 11}}, - {m68k_op_neg_32_d , 0xfff8, 0x4480, { 6, 6, 2, 2}}, - {m68k_op_neg_32_ai , 0xfff8, 0x4490, { 20, 20, 8, 8}}, - {m68k_op_neg_32_pi , 0xfff8, 0x4498, { 20, 20, 8, 8}}, - {m68k_op_neg_32_pd , 0xfff8, 0x44a0, { 22, 22, 9, 9}}, - {m68k_op_neg_32_di , 0xfff8, 0x44a8, { 24, 24, 9, 9}}, - {m68k_op_neg_32_ix , 0xfff8, 0x44b0, { 26, 26, 11, 11}}, - {m68k_op_move_16_toc_d , 0xfff8, 0x44c0, { 12, 12, 4, 4}}, - {m68k_op_move_16_toc_ai , 0xfff8, 0x44d0, { 16, 16, 8, 8}}, - {m68k_op_move_16_toc_pi , 0xfff8, 0x44d8, { 16, 16, 8, 8}}, - {m68k_op_move_16_toc_pd , 0xfff8, 0x44e0, { 18, 18, 9, 9}}, - {m68k_op_move_16_toc_di , 0xfff8, 0x44e8, { 20, 20, 9, 9}}, - {m68k_op_move_16_toc_ix , 0xfff8, 0x44f0, { 22, 22, 11, 11}}, - {m68k_op_not_8_d , 0xfff8, 0x4600, { 4, 4, 2, 2}}, - {m68k_op_not_8_ai , 0xfff8, 0x4610, { 12, 12, 8, 8}}, - {m68k_op_not_8_pi , 0xfff8, 0x4618, { 12, 12, 8, 8}}, - {m68k_op_not_8_pd , 0xfff8, 0x4620, { 14, 14, 9, 9}}, - {m68k_op_not_8_di , 0xfff8, 0x4628, { 16, 16, 9, 9}}, - {m68k_op_not_8_ix , 0xfff8, 0x4630, { 18, 18, 11, 11}}, - {m68k_op_not_16_d , 0xfff8, 0x4640, { 4, 4, 2, 2}}, - {m68k_op_not_16_ai , 0xfff8, 0x4650, { 12, 12, 8, 8}}, - {m68k_op_not_16_pi , 0xfff8, 0x4658, { 12, 12, 8, 8}}, - {m68k_op_not_16_pd , 0xfff8, 0x4660, { 14, 14, 9, 9}}, - {m68k_op_not_16_di , 0xfff8, 0x4668, { 16, 16, 9, 9}}, - {m68k_op_not_16_ix , 0xfff8, 0x4670, { 18, 18, 11, 11}}, - {m68k_op_not_32_d , 0xfff8, 0x4680, { 6, 6, 2, 2}}, - {m68k_op_not_32_ai , 0xfff8, 0x4690, { 20, 20, 8, 8}}, - {m68k_op_not_32_pi , 0xfff8, 0x4698, { 20, 20, 8, 8}}, - {m68k_op_not_32_pd , 0xfff8, 0x46a0, { 22, 22, 9, 9}}, - {m68k_op_not_32_di , 0xfff8, 0x46a8, { 24, 24, 9, 9}}, - {m68k_op_not_32_ix , 0xfff8, 0x46b0, { 26, 26, 11, 11}}, - {m68k_op_move_16_tos_d , 0xfff8, 0x46c0, { 12, 12, 8, 8}}, - {m68k_op_move_16_tos_ai , 0xfff8, 0x46d0, { 16, 16, 12, 12}}, - {m68k_op_move_16_tos_pi , 0xfff8, 0x46d8, { 16, 16, 12, 12}}, - {m68k_op_move_16_tos_pd , 0xfff8, 0x46e0, { 18, 18, 13, 13}}, - {m68k_op_move_16_tos_di , 0xfff8, 0x46e8, { 20, 20, 13, 13}}, - {m68k_op_move_16_tos_ix , 0xfff8, 0x46f0, { 22, 22, 15, 15}}, - {m68k_op_nbcd_8_d , 0xfff8, 0x4800, { 6, 6, 6, 6}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_link_32 , 0xfff8, 0x4808, { 0, 0, 6, 6}}, -#endif - {m68k_op_nbcd_8_ai , 0xfff8, 0x4810, { 12, 12, 10, 10}}, - {m68k_op_nbcd_8_pi , 0xfff8, 0x4818, { 12, 12, 10, 10}}, - {m68k_op_nbcd_8_pd , 0xfff8, 0x4820, { 14, 14, 11, 11}}, - {m68k_op_nbcd_8_di , 0xfff8, 0x4828, { 16, 16, 11, 11}}, - {m68k_op_nbcd_8_ix , 0xfff8, 0x4830, { 18, 18, 13, 13}}, - {m68k_op_swap_32 , 0xfff8, 0x4840, { 4, 4, 4, 4}}, -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_bkpt , 0xfff8, 0x4848, { 0, 10, 10, 10}}, -#endif - {m68k_op_pea_32_ai , 0xfff8, 0x4850, { 12, 12, 9, 9}}, - {m68k_op_pea_32_di , 0xfff8, 0x4868, { 16, 16, 10, 10}}, - {m68k_op_pea_32_ix , 0xfff8, 0x4870, { 20, 20, 12, 12}}, - {m68k_op_ext_16 , 0xfff8, 0x4880, { 4, 4, 4, 4}}, - {m68k_op_movem_16_re_ai , 0xfff8, 0x4890, { 8, 8, 8, 8}}, - {m68k_op_movem_16_re_pd , 0xfff8, 0x48a0, { 8, 8, 4, 4}}, - {m68k_op_movem_16_re_di , 0xfff8, 0x48a8, { 12, 12, 9, 9}}, - {m68k_op_movem_16_re_ix , 0xfff8, 0x48b0, { 14, 14, 11, 11}}, - {m68k_op_ext_32 , 0xfff8, 0x48c0, { 4, 4, 4, 4}}, - {m68k_op_movem_32_re_ai , 0xfff8, 0x48d0, { 8, 8, 8, 8}}, - {m68k_op_movem_32_re_pd , 0xfff8, 0x48e0, { 8, 8, 4, 4}}, - {m68k_op_movem_32_re_di , 0xfff8, 0x48e8, { 12, 12, 9, 9}}, - {m68k_op_movem_32_re_ix , 0xfff8, 0x48f0, { 14, 14, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_extb_32 , 0xfff8, 0x49c0, { 0, 0, 4, 4}}, -#endif - {m68k_op_tst_8_d , 0xfff8, 0x4a00, { 4, 4, 2, 2}}, - {m68k_op_tst_8_ai , 0xfff8, 0x4a10, { 8, 8, 6, 6}}, - {m68k_op_tst_8_pi , 0xfff8, 0x4a18, { 8, 8, 6, 6}}, - {m68k_op_tst_8_pd , 0xfff8, 0x4a20, { 10, 10, 7, 7}}, - {m68k_op_tst_8_di , 0xfff8, 0x4a28, { 12, 12, 7, 7}}, - {m68k_op_tst_8_ix , 0xfff8, 0x4a30, { 14, 14, 9, 9}}, - {m68k_op_tst_16_d , 0xfff8, 0x4a40, { 4, 4, 2, 2}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_tst_16_a , 0xfff8, 0x4a48, { 0, 0, 2, 2}}, -#endif - {m68k_op_tst_16_ai , 0xfff8, 0x4a50, { 8, 8, 6, 6}}, - {m68k_op_tst_16_pi , 0xfff8, 0x4a58, { 8, 8, 6, 6}}, - {m68k_op_tst_16_pd , 0xfff8, 0x4a60, { 10, 10, 7, 7}}, - {m68k_op_tst_16_di , 0xfff8, 0x4a68, { 12, 12, 7, 7}}, - {m68k_op_tst_16_ix , 0xfff8, 0x4a70, { 14, 14, 9, 9}}, - {m68k_op_tst_32_d , 0xfff8, 0x4a80, { 4, 4, 2, 2}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_tst_32_a , 0xfff8, 0x4a88, { 0, 0, 2, 2}}, -#endif - {m68k_op_tst_32_ai , 0xfff8, 0x4a90, { 12, 12, 6, 6}}, - {m68k_op_tst_32_pi , 0xfff8, 0x4a98, { 12, 12, 6, 6}}, - {m68k_op_tst_32_pd , 0xfff8, 0x4aa0, { 14, 14, 7, 7}}, - {m68k_op_tst_32_di , 0xfff8, 0x4aa8, { 16, 16, 7, 7}}, - {m68k_op_tst_32_ix , 0xfff8, 0x4ab0, { 18, 18, 9, 9}}, - {m68k_op_tas_8_d , 0xfff8, 0x4ac0, { 4, 4, 4, 4}}, - {m68k_op_tas_8_ai , 0xfff8, 0x4ad0, { 18, 18, 16, 16}}, - {m68k_op_tas_8_pi , 0xfff8, 0x4ad8, { 18, 18, 16, 16}}, - {m68k_op_tas_8_pd , 0xfff8, 0x4ae0, { 20, 20, 17, 17}}, - {m68k_op_tas_8_di , 0xfff8, 0x4ae8, { 22, 22, 17, 17}}, - {m68k_op_tas_8_ix , 0xfff8, 0x4af0, { 24, 24, 19, 19}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_mull_32_d , 0xfff8, 0x4c00, { 0, 0, 43, 43}}, - {m68k_op_mull_32_ai , 0xfff8, 0x4c10, { 0, 0, 47, 47}}, - {m68k_op_mull_32_pi , 0xfff8, 0x4c18, { 0, 0, 47, 47}}, - {m68k_op_mull_32_pd , 0xfff8, 0x4c20, { 0, 0, 48, 48}}, - {m68k_op_mull_32_di , 0xfff8, 0x4c28, { 0, 0, 48, 48}}, - {m68k_op_mull_32_ix , 0xfff8, 0x4c30, { 0, 0, 50, 50}}, - {m68k_op_divl_32_d , 0xfff8, 0x4c40, { 0, 0, 84, 84}}, - {m68k_op_divl_32_ai , 0xfff8, 0x4c50, { 0, 0, 88, 88}}, - {m68k_op_divl_32_pi , 0xfff8, 0x4c58, { 0, 0, 88, 88}}, - {m68k_op_divl_32_pd , 0xfff8, 0x4c60, { 0, 0, 89, 89}}, - {m68k_op_divl_32_di , 0xfff8, 0x4c68, { 0, 0, 89, 89}}, - {m68k_op_divl_32_ix , 0xfff8, 0x4c70, { 0, 0, 91, 91}}, -#endif - {m68k_op_movem_16_er_ai , 0xfff8, 0x4c90, { 12, 12, 12, 12}}, - {m68k_op_movem_16_er_pi , 0xfff8, 0x4c98, { 12, 12, 8, 8}}, - {m68k_op_movem_16_er_di , 0xfff8, 0x4ca8, { 16, 16, 13, 13}}, - {m68k_op_movem_16_er_ix , 0xfff8, 0x4cb0, { 18, 18, 15, 15}}, - {m68k_op_movem_32_er_ai , 0xfff8, 0x4cd0, { 12, 12, 12, 12}}, - {m68k_op_movem_32_er_pi , 0xfff8, 0x4cd8, { 12, 12, 8, 8}}, - {m68k_op_movem_32_er_di , 0xfff8, 0x4ce8, { 16, 16, 13, 13}}, - {m68k_op_movem_32_er_ix , 0xfff8, 0x4cf0, { 18, 18, 15, 15}}, - {m68k_op_link_16 , 0xfff8, 0x4e50, { 16, 16, 5, 5}}, - {m68k_op_unlk_32 , 0xfff8, 0x4e58, { 12, 12, 6, 6}}, - {m68k_op_move_32_tou , 0xfff8, 0x4e60, { 4, 6, 2, 2}}, - {m68k_op_move_32_fru , 0xfff8, 0x4e68, { 4, 6, 2, 2}}, - {m68k_op_jsr_32_ai , 0xfff8, 0x4e90, { 16, 16, 4, 4}}, - {m68k_op_jsr_32_di , 0xfff8, 0x4ea8, { 18, 18, 5, 5}}, - {m68k_op_jsr_32_ix , 0xfff8, 0x4eb0, { 22, 22, 7, 7}}, - {m68k_op_jmp_32_ai , 0xfff8, 0x4ed0, { 8, 8, 4, 4}}, - {m68k_op_jmp_32_di , 0xfff8, 0x4ee8, { 10, 10, 5, 5}}, - {m68k_op_jmp_32_ix , 0xfff8, 0x4ef0, { 14, 14, 7, 7}}, - {m68k_op_st_8_d , 0xfff8, 0x50c0, { 6, 4, 4, 4}}, - {m68k_op_dbt_16 , 0xfff8, 0x50c8, { 12, 12, 6, 6}}, - {m68k_op_st_8_ai , 0xfff8, 0x50d0, { 12, 12, 10, 10}}, - {m68k_op_st_8_pi , 0xfff8, 0x50d8, { 12, 12, 10, 10}}, - {m68k_op_st_8_pd , 0xfff8, 0x50e0, { 14, 14, 11, 11}}, - {m68k_op_st_8_di , 0xfff8, 0x50e8, { 16, 16, 11, 11}}, - {m68k_op_st_8_ix , 0xfff8, 0x50f0, { 18, 18, 13, 13}}, - {m68k_op_sf_8_d , 0xfff8, 0x51c0, { 4, 4, 4, 4}}, - {m68k_op_dbf_16 , 0xfff8, 0x51c8, { 12, 12, 6, 6}}, - {m68k_op_sf_8_ai , 0xfff8, 0x51d0, { 12, 12, 10, 10}}, - {m68k_op_sf_8_pi , 0xfff8, 0x51d8, { 12, 12, 10, 10}}, - {m68k_op_sf_8_pd , 0xfff8, 0x51e0, { 14, 14, 11, 11}}, - {m68k_op_sf_8_di , 0xfff8, 0x51e8, { 16, 16, 11, 11}}, - {m68k_op_sf_8_ix , 0xfff8, 0x51f0, { 18, 18, 13, 13}}, - {m68k_op_shi_8_d , 0xfff8, 0x52c0, { 4, 4, 4, 4}}, - {m68k_op_dbhi_16 , 0xfff8, 0x52c8, { 12, 12, 6, 6}}, - {m68k_op_shi_8_ai , 0xfff8, 0x52d0, { 12, 12, 10, 10}}, - {m68k_op_shi_8_pi , 0xfff8, 0x52d8, { 12, 12, 10, 10}}, - {m68k_op_shi_8_pd , 0xfff8, 0x52e0, { 14, 14, 11, 11}}, - {m68k_op_shi_8_di , 0xfff8, 0x52e8, { 16, 16, 11, 11}}, - {m68k_op_shi_8_ix , 0xfff8, 0x52f0, { 18, 18, 13, 13}}, - {m68k_op_sls_8_d , 0xfff8, 0x53c0, { 4, 4, 4, 4}}, - {m68k_op_dbls_16 , 0xfff8, 0x53c8, { 12, 12, 6, 6}}, - {m68k_op_sls_8_ai , 0xfff8, 0x53d0, { 12, 12, 10, 10}}, - {m68k_op_sls_8_pi , 0xfff8, 0x53d8, { 12, 12, 10, 10}}, - {m68k_op_sls_8_pd , 0xfff8, 0x53e0, { 14, 14, 11, 11}}, - {m68k_op_sls_8_di , 0xfff8, 0x53e8, { 16, 16, 11, 11}}, - {m68k_op_sls_8_ix , 0xfff8, 0x53f0, { 18, 18, 13, 13}}, - {m68k_op_scc_8_d , 0xfff8, 0x54c0, { 4, 4, 4, 4}}, - {m68k_op_dbcc_16 , 0xfff8, 0x54c8, { 12, 12, 6, 6}}, - {m68k_op_scc_8_ai , 0xfff8, 0x54d0, { 12, 12, 10, 10}}, - {m68k_op_scc_8_pi , 0xfff8, 0x54d8, { 12, 12, 10, 10}}, - {m68k_op_scc_8_pd , 0xfff8, 0x54e0, { 14, 14, 11, 11}}, - {m68k_op_scc_8_di , 0xfff8, 0x54e8, { 16, 16, 11, 11}}, - {m68k_op_scc_8_ix , 0xfff8, 0x54f0, { 18, 18, 13, 13}}, - {m68k_op_scs_8_d , 0xfff8, 0x55c0, { 4, 4, 4, 4}}, - {m68k_op_dbcs_16 , 0xfff8, 0x55c8, { 12, 12, 6, 6}}, - {m68k_op_scs_8_ai , 0xfff8, 0x55d0, { 12, 12, 10, 10}}, - {m68k_op_scs_8_pi , 0xfff8, 0x55d8, { 12, 12, 10, 10}}, - {m68k_op_scs_8_pd , 0xfff8, 0x55e0, { 14, 14, 11, 11}}, - {m68k_op_scs_8_di , 0xfff8, 0x55e8, { 16, 16, 11, 11}}, - {m68k_op_scs_8_ix , 0xfff8, 0x55f0, { 18, 18, 13, 13}}, - {m68k_op_sne_8_d , 0xfff8, 0x56c0, { 4, 4, 4, 4}}, - {m68k_op_dbne_16 , 0xfff8, 0x56c8, { 12, 12, 6, 6}}, - {m68k_op_sne_8_ai , 0xfff8, 0x56d0, { 12, 12, 10, 10}}, - {m68k_op_sne_8_pi , 0xfff8, 0x56d8, { 12, 12, 10, 10}}, - {m68k_op_sne_8_pd , 0xfff8, 0x56e0, { 14, 14, 11, 11}}, - {m68k_op_sne_8_di , 0xfff8, 0x56e8, { 16, 16, 11, 11}}, - {m68k_op_sne_8_ix , 0xfff8, 0x56f0, { 18, 18, 13, 13}}, - {m68k_op_seq_8_d , 0xfff8, 0x57c0, { 4, 4, 4, 4}}, - {m68k_op_dbeq_16 , 0xfff8, 0x57c8, { 12, 12, 6, 6}}, - {m68k_op_seq_8_ai , 0xfff8, 0x57d0, { 12, 12, 10, 10}}, - {m68k_op_seq_8_pi , 0xfff8, 0x57d8, { 12, 12, 10, 10}}, - {m68k_op_seq_8_pd , 0xfff8, 0x57e0, { 14, 14, 11, 11}}, - {m68k_op_seq_8_di , 0xfff8, 0x57e8, { 16, 16, 11, 11}}, - {m68k_op_seq_8_ix , 0xfff8, 0x57f0, { 18, 18, 13, 13}}, - {m68k_op_svc_8_d , 0xfff8, 0x58c0, { 4, 4, 4, 4}}, - {m68k_op_dbvc_16 , 0xfff8, 0x58c8, { 12, 12, 6, 6}}, - {m68k_op_svc_8_ai , 0xfff8, 0x58d0, { 12, 12, 10, 10}}, - {m68k_op_svc_8_pi , 0xfff8, 0x58d8, { 12, 12, 10, 10}}, - {m68k_op_svc_8_pd , 0xfff8, 0x58e0, { 14, 14, 11, 11}}, - {m68k_op_svc_8_di , 0xfff8, 0x58e8, { 16, 16, 11, 11}}, - {m68k_op_svc_8_ix , 0xfff8, 0x58f0, { 18, 18, 13, 13}}, - {m68k_op_svs_8_d , 0xfff8, 0x59c0, { 4, 4, 4, 4}}, - {m68k_op_dbvs_16 , 0xfff8, 0x59c8, { 12, 12, 6, 6}}, - {m68k_op_svs_8_ai , 0xfff8, 0x59d0, { 12, 12, 10, 10}}, - {m68k_op_svs_8_pi , 0xfff8, 0x59d8, { 12, 12, 10, 10}}, - {m68k_op_svs_8_pd , 0xfff8, 0x59e0, { 14, 14, 11, 11}}, - {m68k_op_svs_8_di , 0xfff8, 0x59e8, { 16, 16, 11, 11}}, - {m68k_op_svs_8_ix , 0xfff8, 0x59f0, { 18, 18, 13, 13}}, - {m68k_op_spl_8_d , 0xfff8, 0x5ac0, { 4, 4, 4, 4}}, - {m68k_op_dbpl_16 , 0xfff8, 0x5ac8, { 12, 12, 6, 6}}, - {m68k_op_spl_8_ai , 0xfff8, 0x5ad0, { 12, 12, 10, 10}}, - {m68k_op_spl_8_pi , 0xfff8, 0x5ad8, { 12, 12, 10, 10}}, - {m68k_op_spl_8_pd , 0xfff8, 0x5ae0, { 14, 14, 11, 11}}, - {m68k_op_spl_8_di , 0xfff8, 0x5ae8, { 16, 16, 11, 11}}, - {m68k_op_spl_8_ix , 0xfff8, 0x5af0, { 18, 18, 13, 13}}, - {m68k_op_smi_8_d , 0xfff8, 0x5bc0, { 4, 4, 4, 4}}, - {m68k_op_dbmi_16 , 0xfff8, 0x5bc8, { 12, 12, 6, 6}}, - {m68k_op_smi_8_ai , 0xfff8, 0x5bd0, { 12, 12, 10, 10}}, - {m68k_op_smi_8_pi , 0xfff8, 0x5bd8, { 12, 12, 10, 10}}, - {m68k_op_smi_8_pd , 0xfff8, 0x5be0, { 14, 14, 11, 11}}, - {m68k_op_smi_8_di , 0xfff8, 0x5be8, { 16, 16, 11, 11}}, - {m68k_op_smi_8_ix , 0xfff8, 0x5bf0, { 18, 18, 13, 13}}, - {m68k_op_sge_8_d , 0xfff8, 0x5cc0, { 4, 4, 4, 4}}, - {m68k_op_dbge_16 , 0xfff8, 0x5cc8, { 12, 12, 6, 6}}, - {m68k_op_sge_8_ai , 0xfff8, 0x5cd0, { 12, 12, 10, 10}}, - {m68k_op_sge_8_pi , 0xfff8, 0x5cd8, { 12, 12, 10, 10}}, - {m68k_op_sge_8_pd , 0xfff8, 0x5ce0, { 14, 14, 11, 11}}, - {m68k_op_sge_8_di , 0xfff8, 0x5ce8, { 16, 16, 11, 11}}, - {m68k_op_sge_8_ix , 0xfff8, 0x5cf0, { 18, 18, 13, 13}}, - {m68k_op_slt_8_d , 0xfff8, 0x5dc0, { 4, 4, 4, 4}}, - {m68k_op_dblt_16 , 0xfff8, 0x5dc8, { 12, 12, 6, 6}}, - {m68k_op_slt_8_ai , 0xfff8, 0x5dd0, { 12, 12, 10, 10}}, - {m68k_op_slt_8_pi , 0xfff8, 0x5dd8, { 12, 12, 10, 10}}, - {m68k_op_slt_8_pd , 0xfff8, 0x5de0, { 14, 14, 11, 11}}, - {m68k_op_slt_8_di , 0xfff8, 0x5de8, { 16, 16, 11, 11}}, - {m68k_op_slt_8_ix , 0xfff8, 0x5df0, { 18, 18, 13, 13}}, - {m68k_op_sgt_8_d , 0xfff8, 0x5ec0, { 4, 4, 4, 4}}, - {m68k_op_dbgt_16 , 0xfff8, 0x5ec8, { 12, 12, 6, 6}}, - {m68k_op_sgt_8_ai , 0xfff8, 0x5ed0, { 12, 12, 10, 10}}, - {m68k_op_sgt_8_pi , 0xfff8, 0x5ed8, { 12, 12, 10, 10}}, - {m68k_op_sgt_8_pd , 0xfff8, 0x5ee0, { 14, 14, 11, 11}}, - {m68k_op_sgt_8_di , 0xfff8, 0x5ee8, { 16, 16, 11, 11}}, - {m68k_op_sgt_8_ix , 0xfff8, 0x5ef0, { 18, 18, 13, 13}}, - {m68k_op_sle_8_d , 0xfff8, 0x5fc0, { 4, 4, 4, 4}}, - {m68k_op_dble_16 , 0xfff8, 0x5fc8, { 12, 12, 6, 6}}, - {m68k_op_sle_8_ai , 0xfff8, 0x5fd0, { 12, 12, 10, 10}}, - {m68k_op_sle_8_pi , 0xfff8, 0x5fd8, { 12, 12, 10, 10}}, - {m68k_op_sle_8_pd , 0xfff8, 0x5fe0, { 14, 14, 11, 11}}, - {m68k_op_sle_8_di , 0xfff8, 0x5fe8, { 16, 16, 11, 11}}, - {m68k_op_sle_8_ix , 0xfff8, 0x5ff0, { 18, 18, 13, 13}}, - {m68k_op_sbcd_8_mm_ax7 , 0xfff8, 0x8f08, { 18, 18, 16, 16}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_pack_16_mm_ax7 , 0xfff8, 0x8f48, { 0, 0, 13, 13}}, - {m68k_op_unpk_16_mm_ax7 , 0xfff8, 0x8f88, { 0, 0, 13, 13}}, -#endif - {m68k_op_subx_8_mm_ax7 , 0xfff8, 0x9f08, { 18, 18, 12, 12}}, - {m68k_op_cmpm_8_ax7 , 0xfff8, 0xbf08, { 12, 12, 9, 9}}, - {m68k_op_abcd_8_mm_ax7 , 0xfff8, 0xcf08, { 18, 18, 16, 16}}, - {m68k_op_addx_8_mm_ax7 , 0xfff8, 0xdf08, { 18, 18, 12, 12}}, - {m68k_op_asr_16_ai , 0xfff8, 0xe0d0, { 12, 12, 9, 9}}, - {m68k_op_asr_16_pi , 0xfff8, 0xe0d8, { 12, 12, 9, 9}}, - {m68k_op_asr_16_pd , 0xfff8, 0xe0e0, { 14, 14, 10, 10}}, - {m68k_op_asr_16_di , 0xfff8, 0xe0e8, { 16, 16, 10, 10}}, - {m68k_op_asr_16_ix , 0xfff8, 0xe0f0, { 18, 18, 12, 12}}, - {m68k_op_asl_16_ai , 0xfff8, 0xe1d0, { 12, 12, 10, 10}}, - {m68k_op_asl_16_pi , 0xfff8, 0xe1d8, { 12, 12, 10, 10}}, - {m68k_op_asl_16_pd , 0xfff8, 0xe1e0, { 14, 14, 11, 11}}, - {m68k_op_asl_16_di , 0xfff8, 0xe1e8, { 16, 16, 11, 11}}, - {m68k_op_asl_16_ix , 0xfff8, 0xe1f0, { 18, 18, 13, 13}}, - {m68k_op_lsr_16_ai , 0xfff8, 0xe2d0, { 12, 12, 9, 9}}, - {m68k_op_lsr_16_pi , 0xfff8, 0xe2d8, { 12, 12, 9, 9}}, - {m68k_op_lsr_16_pd , 0xfff8, 0xe2e0, { 14, 14, 10, 10}}, - {m68k_op_lsr_16_di , 0xfff8, 0xe2e8, { 16, 16, 10, 10}}, - {m68k_op_lsr_16_ix , 0xfff8, 0xe2f0, { 18, 18, 12, 12}}, - {m68k_op_lsl_16_ai , 0xfff8, 0xe3d0, { 12, 12, 9, 9}}, - {m68k_op_lsl_16_pi , 0xfff8, 0xe3d8, { 12, 12, 9, 9}}, - {m68k_op_lsl_16_pd , 0xfff8, 0xe3e0, { 14, 14, 10, 10}}, - {m68k_op_lsl_16_di , 0xfff8, 0xe3e8, { 16, 16, 10, 10}}, - {m68k_op_lsl_16_ix , 0xfff8, 0xe3f0, { 18, 18, 12, 12}}, - {m68k_op_roxr_16_ai , 0xfff8, 0xe4d0, { 12, 12, 9, 9}}, - {m68k_op_roxr_16_pi , 0xfff8, 0xe4d8, { 12, 12, 9, 9}}, - {m68k_op_roxr_16_pd , 0xfff8, 0xe4e0, { 14, 14, 10, 10}}, - {m68k_op_roxr_16_di , 0xfff8, 0xe4e8, { 16, 16, 10, 10}}, - {m68k_op_roxr_16_ix , 0xfff8, 0xe4f0, { 18, 18, 12, 12}}, - {m68k_op_roxl_16_ai , 0xfff8, 0xe5d0, { 12, 12, 9, 9}}, - {m68k_op_roxl_16_pi , 0xfff8, 0xe5d8, { 12, 12, 9, 9}}, - {m68k_op_roxl_16_pd , 0xfff8, 0xe5e0, { 14, 14, 10, 10}}, - {m68k_op_roxl_16_di , 0xfff8, 0xe5e8, { 16, 16, 10, 10}}, - {m68k_op_roxl_16_ix , 0xfff8, 0xe5f0, { 18, 18, 12, 12}}, - {m68k_op_ror_16_ai , 0xfff8, 0xe6d0, { 12, 12, 11, 11}}, - {m68k_op_ror_16_pi , 0xfff8, 0xe6d8, { 12, 12, 11, 11}}, - {m68k_op_ror_16_pd , 0xfff8, 0xe6e0, { 14, 14, 12, 12}}, - {m68k_op_ror_16_di , 0xfff8, 0xe6e8, { 16, 16, 12, 12}}, - {m68k_op_ror_16_ix , 0xfff8, 0xe6f0, { 18, 18, 14, 14}}, - {m68k_op_rol_16_ai , 0xfff8, 0xe7d0, { 12, 12, 11, 11}}, - {m68k_op_rol_16_pi , 0xfff8, 0xe7d8, { 12, 12, 11, 11}}, - {m68k_op_rol_16_pd , 0xfff8, 0xe7e0, { 14, 14, 12, 12}}, - {m68k_op_rol_16_di , 0xfff8, 0xe7e8, { 16, 16, 12, 12}}, - {m68k_op_rol_16_ix , 0xfff8, 0xe7f0, { 18, 18, 14, 14}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_bftst_32_d , 0xfff8, 0xe8c0, { 0, 0, 6, 6}}, - {m68k_op_bftst_32_ai , 0xfff8, 0xe8d0, { 0, 0, 17, 17}}, - {m68k_op_bftst_32_di , 0xfff8, 0xe8e8, { 0, 0, 18, 18}}, - {m68k_op_bftst_32_ix , 0xfff8, 0xe8f0, { 0, 0, 20, 20}}, - {m68k_op_bfextu_32_d , 0xfff8, 0xe9c0, { 0, 0, 8, 8}}, - {m68k_op_bfextu_32_ai , 0xfff8, 0xe9d0, { 0, 0, 19, 19}}, - {m68k_op_bfextu_32_di , 0xfff8, 0xe9e8, { 0, 0, 20, 20}}, - {m68k_op_bfextu_32_ix , 0xfff8, 0xe9f0, { 0, 0, 22, 22}}, - {m68k_op_bfchg_32_d , 0xfff8, 0xeac0, { 0, 0, 12, 12}}, - {m68k_op_bfchg_32_ai , 0xfff8, 0xead0, { 0, 0, 24, 24}}, - {m68k_op_bfchg_32_di , 0xfff8, 0xeae8, { 0, 0, 25, 25}}, - {m68k_op_bfchg_32_ix , 0xfff8, 0xeaf0, { 0, 0, 27, 27}}, - {m68k_op_bfexts_32_d , 0xfff8, 0xebc0, { 0, 0, 8, 8}}, - {m68k_op_bfexts_32_ai , 0xfff8, 0xebd0, { 0, 0, 19, 19}}, - {m68k_op_bfexts_32_di , 0xfff8, 0xebe8, { 0, 0, 20, 20}}, - {m68k_op_bfexts_32_ix , 0xfff8, 0xebf0, { 0, 0, 22, 22}}, - {m68k_op_bfclr_32_d , 0xfff8, 0xecc0, { 0, 0, 12, 12}}, - {m68k_op_bfclr_32_ai , 0xfff8, 0xecd0, { 0, 0, 24, 24}}, - {m68k_op_bfclr_32_di , 0xfff8, 0xece8, { 0, 0, 25, 25}}, - {m68k_op_bfclr_32_ix , 0xfff8, 0xecf0, { 0, 0, 27, 27}}, - {m68k_op_bfffo_32_d , 0xfff8, 0xedc0, { 0, 0, 18, 18}}, - {m68k_op_bfffo_32_ai , 0xfff8, 0xedd0, { 0, 0, 32, 32}}, - {m68k_op_bfffo_32_di , 0xfff8, 0xede8, { 0, 0, 33, 33}}, - {m68k_op_bfffo_32_ix , 0xfff8, 0xedf0, { 0, 0, 35, 35}}, - {m68k_op_bfset_32_d , 0xfff8, 0xeec0, { 0, 0, 12, 12}}, - {m68k_op_bfset_32_ai , 0xfff8, 0xeed0, { 0, 0, 24, 24}}, - {m68k_op_bfset_32_di , 0xfff8, 0xeee8, { 0, 0, 25, 25}}, - {m68k_op_bfset_32_ix , 0xfff8, 0xeef0, { 0, 0, 27, 27}}, - {m68k_op_bfins_32_d , 0xfff8, 0xefc0, { 0, 0, 10, 10}}, - {m68k_op_bfins_32_ai , 0xfff8, 0xefd0, { 0, 0, 21, 21}}, - {m68k_op_bfins_32_di , 0xfff8, 0xefe8, { 0, 0, 22, 22}}, - {m68k_op_bfins_32_ix , 0xfff8, 0xeff0, { 0, 0, 24, 24}}, -#endif - {m68k_op_move16_32 , 0xfff8, 0xf620, { 0, 0, 0, 4}}, /* ???????? */ - {m68k_op_ori_8_pi7 , 0xffff, 0x001f, { 16, 16, 8, 8}}, - {m68k_op_ori_8_pd7 , 0xffff, 0x0027, { 18, 18, 9, 9}}, - {m68k_op_ori_8_aw , 0xffff, 0x0038, { 20, 20, 8, 8}}, - {m68k_op_ori_8_al , 0xffff, 0x0039, { 24, 24, 8, 8}}, - {m68k_op_ori_16_toc , 0xffff, 0x003c, { 20, 16, 12, 12}}, - {m68k_op_ori_16_aw , 0xffff, 0x0078, { 20, 20, 8, 8}}, - {m68k_op_ori_16_al , 0xffff, 0x0079, { 24, 24, 8, 8}}, - {m68k_op_ori_16_tos , 0xffff, 0x007c, { 20, 16, 12, 12}}, - {m68k_op_ori_32_aw , 0xffff, 0x00b8, { 32, 32, 8, 8}}, - {m68k_op_ori_32_al , 0xffff, 0x00b9, { 36, 36, 8, 8}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_chk2cmp2_8_aw , 0xffff, 0x00f8, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_8_al , 0xffff, 0x00f9, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_8_pcdi , 0xffff, 0x00fa, { 0, 0, 23, 23}}, - {m68k_op_chk2cmp2_8_pcix , 0xffff, 0x00fb, { 0, 0, 23, 23}}, -#endif - {m68k_op_andi_8_pi7 , 0xffff, 0x021f, { 16, 16, 8, 8}}, - {m68k_op_andi_8_pd7 , 0xffff, 0x0227, { 18, 18, 9, 9}}, - {m68k_op_andi_8_aw , 0xffff, 0x0238, { 20, 20, 8, 8}}, - {m68k_op_andi_8_al , 0xffff, 0x0239, { 24, 24, 8, 8}}, - {m68k_op_andi_16_toc , 0xffff, 0x023c, { 20, 16, 12, 12}}, - {m68k_op_andi_16_aw , 0xffff, 0x0278, { 20, 20, 8, 8}}, - {m68k_op_andi_16_al , 0xffff, 0x0279, { 24, 24, 8, 8}}, - {m68k_op_andi_16_tos , 0xffff, 0x027c, { 20, 16, 12, 12}}, - {m68k_op_andi_32_aw , 0xffff, 0x02b8, { 32, 32, 8, 8}}, - {m68k_op_andi_32_al , 0xffff, 0x02b9, { 36, 36, 8, 8}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_chk2cmp2_16_aw , 0xffff, 0x02f8, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_16_al , 0xffff, 0x02f9, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_16_pcdi , 0xffff, 0x02fa, { 0, 0, 23, 23}}, - {m68k_op_chk2cmp2_16_pcix , 0xffff, 0x02fb, { 0, 0, 23, 23}}, -#endif - {m68k_op_subi_8_pi7 , 0xffff, 0x041f, { 16, 16, 8, 8}}, - {m68k_op_subi_8_pd7 , 0xffff, 0x0427, { 18, 18, 9, 9}}, - {m68k_op_subi_8_aw , 0xffff, 0x0438, { 20, 20, 8, 8}}, - {m68k_op_subi_8_al , 0xffff, 0x0439, { 24, 24, 8, 8}}, - {m68k_op_subi_16_aw , 0xffff, 0x0478, { 20, 20, 8, 8}}, - {m68k_op_subi_16_al , 0xffff, 0x0479, { 24, 24, 8, 8}}, - {m68k_op_subi_32_aw , 0xffff, 0x04b8, { 32, 32, 8, 8}}, - {m68k_op_subi_32_al , 0xffff, 0x04b9, { 36, 36, 8, 8}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_chk2cmp2_32_aw , 0xffff, 0x04f8, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_32_al , 0xffff, 0x04f9, { 0, 0, 22, 22}}, - {m68k_op_chk2cmp2_32_pcdi , 0xffff, 0x04fa, { 0, 0, 23, 23}}, - {m68k_op_chk2cmp2_32_pcix , 0xffff, 0x04fb, { 0, 0, 23, 23}}, -#endif - {m68k_op_addi_8_pi7 , 0xffff, 0x061f, { 16, 16, 8, 8}}, - {m68k_op_addi_8_pd7 , 0xffff, 0x0627, { 18, 18, 9, 9}}, - {m68k_op_addi_8_aw , 0xffff, 0x0638, { 20, 20, 8, 8}}, - {m68k_op_addi_8_al , 0xffff, 0x0639, { 24, 24, 8, 8}}, - {m68k_op_addi_16_aw , 0xffff, 0x0678, { 20, 20, 8, 8}}, - {m68k_op_addi_16_al , 0xffff, 0x0679, { 24, 24, 8, 8}}, - {m68k_op_addi_32_aw , 0xffff, 0x06b8, { 32, 32, 8, 8}}, - {m68k_op_addi_32_al , 0xffff, 0x06b9, { 36, 36, 8, 8}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_callm_32_aw , 0xffff, 0x06f8, { 0, 0, 64, 64}}, - {m68k_op_callm_32_al , 0xffff, 0x06f9, { 0, 0, 64, 64}}, - {m68k_op_callm_32_pcdi , 0xffff, 0x06fa, { 0, 0, 65, 65}}, - {m68k_op_callm_32_pcix , 0xffff, 0x06fb, { 0, 0, 67, 67}}, -#endif - {m68k_op_btst_8_s_pi7 , 0xffff, 0x081f, { 12, 12, 8, 8}}, - {m68k_op_btst_8_s_pd7 , 0xffff, 0x0827, { 14, 14, 9, 9}}, - {m68k_op_btst_8_s_aw , 0xffff, 0x0838, { 16, 16, 8, 8}}, - {m68k_op_btst_8_s_al , 0xffff, 0x0839, { 20, 20, 8, 8}}, - {m68k_op_btst_8_s_pcdi , 0xffff, 0x083a, { 16, 16, 9, 9}}, - {m68k_op_btst_8_s_pcix , 0xffff, 0x083b, { 18, 18, 11, 11}}, - {m68k_op_bchg_8_s_pi7 , 0xffff, 0x085f, { 16, 16, 8, 8}}, - {m68k_op_bchg_8_s_pd7 , 0xffff, 0x0867, { 18, 18, 9, 9}}, - {m68k_op_bchg_8_s_aw , 0xffff, 0x0878, { 20, 20, 8, 8}}, - {m68k_op_bchg_8_s_al , 0xffff, 0x0879, { 24, 24, 8, 8}}, - {m68k_op_bclr_8_s_pi7 , 0xffff, 0x089f, { 16, 16, 8, 8}}, - {m68k_op_bclr_8_s_pd7 , 0xffff, 0x08a7, { 18, 18, 9, 9}}, - {m68k_op_bclr_8_s_aw , 0xffff, 0x08b8, { 20, 20, 8, 8}}, - {m68k_op_bclr_8_s_al , 0xffff, 0x08b9, { 24, 24, 8, 8}}, - {m68k_op_bset_8_s_pi7 , 0xffff, 0x08df, { 16, 16, 8, 8}}, - {m68k_op_bset_8_s_pd7 , 0xffff, 0x08e7, { 18, 18, 9, 9}}, - {m68k_op_bset_8_s_aw , 0xffff, 0x08f8, { 20, 20, 8, 8}}, - {m68k_op_bset_8_s_al , 0xffff, 0x08f9, { 24, 24, 8, 8}}, - {m68k_op_eori_8_pi7 , 0xffff, 0x0a1f, { 16, 16, 8, 8}}, - {m68k_op_eori_8_pd7 , 0xffff, 0x0a27, { 18, 18, 9, 9}}, - {m68k_op_eori_8_aw , 0xffff, 0x0a38, { 20, 20, 8, 8}}, - {m68k_op_eori_8_al , 0xffff, 0x0a39, { 24, 24, 8, 8}}, - {m68k_op_eori_16_toc , 0xffff, 0x0a3c, { 20, 16, 12, 12}}, - {m68k_op_eori_16_aw , 0xffff, 0x0a78, { 20, 20, 8, 8}}, - {m68k_op_eori_16_al , 0xffff, 0x0a79, { 24, 24, 8, 8}}, - {m68k_op_eori_16_tos , 0xffff, 0x0a7c, { 20, 16, 12, 12}}, - {m68k_op_eori_32_aw , 0xffff, 0x0ab8, { 32, 32, 8, 8}}, - {m68k_op_eori_32_al , 0xffff, 0x0ab9, { 36, 36, 8, 8}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cas_8_pi7 , 0xffff, 0x0adf, { 0, 0, 16, 16}}, - {m68k_op_cas_8_pd7 , 0xffff, 0x0ae7, { 0, 0, 17, 17}}, - {m68k_op_cas_8_aw , 0xffff, 0x0af8, { 0, 0, 16, 16}}, - {m68k_op_cas_8_al , 0xffff, 0x0af9, { 0, 0, 16, 16}}, -#endif - {m68k_op_cmpi_8_pi7 , 0xffff, 0x0c1f, { 12, 12, 6, 6}}, - {m68k_op_cmpi_8_pd7 , 0xffff, 0x0c27, { 14, 14, 7, 7}}, - {m68k_op_cmpi_8_aw , 0xffff, 0x0c38, { 16, 16, 6, 6}}, - {m68k_op_cmpi_8_al , 0xffff, 0x0c39, { 20, 20, 6, 6}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cmpi_8_pcdi , 0xffff, 0x0c3a, { 0, 0, 7, 7}}, - {m68k_op_cmpi_8_pcix , 0xffff, 0x0c3b, { 0, 0, 9, 9}}, -#endif - {m68k_op_cmpi_16_aw , 0xffff, 0x0c78, { 16, 16, 6, 6}}, - {m68k_op_cmpi_16_al , 0xffff, 0x0c79, { 20, 20, 6, 6}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cmpi_16_pcdi , 0xffff, 0x0c7a, { 0, 0, 7, 7}}, - {m68k_op_cmpi_16_pcix , 0xffff, 0x0c7b, { 0, 0, 9, 9}}, -#endif - {m68k_op_cmpi_32_aw , 0xffff, 0x0cb8, { 24, 24, 6, 6}}, - {m68k_op_cmpi_32_al , 0xffff, 0x0cb9, { 28, 28, 6, 6}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cmpi_32_pcdi , 0xffff, 0x0cba, { 0, 0, 7, 7}}, - {m68k_op_cmpi_32_pcix , 0xffff, 0x0cbb, { 0, 0, 9, 9}}, - {m68k_op_cas_16_aw , 0xffff, 0x0cf8, { 0, 0, 16, 16}}, - {m68k_op_cas_16_al , 0xffff, 0x0cf9, { 0, 0, 16, 16}}, - {m68k_op_cas2_16 , 0xffff, 0x0cfc, { 0, 0, 12, 12}}, -#endif -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_moves_8_pi7 , 0xffff, 0x0e1f, { 0, 18, 9, 9}}, - {m68k_op_moves_8_pd7 , 0xffff, 0x0e27, { 0, 20, 10, 10}}, - {m68k_op_moves_8_aw , 0xffff, 0x0e38, { 0, 26, 9, 9}}, - {m68k_op_moves_8_al , 0xffff, 0x0e39, { 0, 30, 9, 9}}, - {m68k_op_moves_16_aw , 0xffff, 0x0e78, { 0, 26, 9, 9}}, - {m68k_op_moves_16_al , 0xffff, 0x0e79, { 0, 30, 9, 9}}, - {m68k_op_moves_32_aw , 0xffff, 0x0eb8, { 0, 32, 9, 9}}, - {m68k_op_moves_32_al , 0xffff, 0x0eb9, { 0, 36, 9, 9}}, -#endif -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_cas_32_aw , 0xffff, 0x0ef8, { 0, 0, 16, 16}}, - {m68k_op_cas_32_al , 0xffff, 0x0ef9, { 0, 0, 16, 16}}, - {m68k_op_cas2_32 , 0xffff, 0x0efc, { 0, 0, 12, 12}}, -#endif - {m68k_op_move_8_aw_pi7 , 0xffff, 0x11df, { 16, 16, 8, 8}}, - {m68k_op_move_8_aw_pd7 , 0xffff, 0x11e7, { 18, 18, 9, 9}}, - {m68k_op_move_8_aw_aw , 0xffff, 0x11f8, { 20, 20, 8, 8}}, - {m68k_op_move_8_aw_al , 0xffff, 0x11f9, { 24, 24, 8, 8}}, - {m68k_op_move_8_aw_pcdi , 0xffff, 0x11fa, { 20, 20, 9, 9}}, - {m68k_op_move_8_aw_pcix , 0xffff, 0x11fb, { 22, 22, 11, 11}}, - {m68k_op_move_8_aw_i , 0xffff, 0x11fc, { 16, 16, 6, 6}}, - {m68k_op_move_8_al_pi7 , 0xffff, 0x13df, { 20, 20, 10, 10}}, - {m68k_op_move_8_al_pd7 , 0xffff, 0x13e7, { 22, 22, 11, 11}}, - {m68k_op_move_8_al_aw , 0xffff, 0x13f8, { 24, 24, 10, 10}}, - {m68k_op_move_8_al_al , 0xffff, 0x13f9, { 28, 28, 10, 10}}, - {m68k_op_move_8_al_pcdi , 0xffff, 0x13fa, { 24, 24, 11, 11}}, - {m68k_op_move_8_al_pcix , 0xffff, 0x13fb, { 26, 26, 13, 13}}, - {m68k_op_move_8_al_i , 0xffff, 0x13fc, { 20, 20, 8, 8}}, - {m68k_op_move_8_pi7_pi7 , 0xffff, 0x1edf, { 12, 12, 8, 8}}, - {m68k_op_move_8_pi7_pd7 , 0xffff, 0x1ee7, { 14, 14, 9, 9}}, - {m68k_op_move_8_pi7_aw , 0xffff, 0x1ef8, { 16, 16, 8, 8}}, - {m68k_op_move_8_pi7_al , 0xffff, 0x1ef9, { 20, 20, 8, 8}}, - {m68k_op_move_8_pi7_pcdi , 0xffff, 0x1efa, { 16, 16, 9, 9}}, - {m68k_op_move_8_pi7_pcix , 0xffff, 0x1efb, { 18, 18, 11, 11}}, - {m68k_op_move_8_pi7_i , 0xffff, 0x1efc, { 12, 12, 6, 6}}, - {m68k_op_move_8_pd7_pi7 , 0xffff, 0x1f1f, { 12, 12, 9, 9}}, - {m68k_op_move_8_pd7_pd7 , 0xffff, 0x1f27, { 14, 14, 10, 10}}, - {m68k_op_move_8_pd7_aw , 0xffff, 0x1f38, { 16, 16, 9, 9}}, - {m68k_op_move_8_pd7_al , 0xffff, 0x1f39, { 20, 20, 9, 9}}, - {m68k_op_move_8_pd7_pcdi , 0xffff, 0x1f3a, { 16, 16, 10, 10}}, - {m68k_op_move_8_pd7_pcix , 0xffff, 0x1f3b, { 18, 18, 12, 12}}, - {m68k_op_move_8_pd7_i , 0xffff, 0x1f3c, { 12, 12, 7, 7}}, - {m68k_op_move_32_aw_aw , 0xffff, 0x21f8, { 28, 28, 8, 8}}, - {m68k_op_move_32_aw_al , 0xffff, 0x21f9, { 32, 32, 8, 8}}, - {m68k_op_move_32_aw_pcdi , 0xffff, 0x21fa, { 28, 28, 9, 9}}, - {m68k_op_move_32_aw_pcix , 0xffff, 0x21fb, { 30, 30, 11, 11}}, - {m68k_op_move_32_aw_i , 0xffff, 0x21fc, { 24, 24, 8, 8}}, - {m68k_op_move_32_al_aw , 0xffff, 0x23f8, { 32, 32, 10, 10}}, - {m68k_op_move_32_al_al , 0xffff, 0x23f9, { 36, 36, 10, 10}}, - {m68k_op_move_32_al_pcdi , 0xffff, 0x23fa, { 32, 32, 11, 11}}, - {m68k_op_move_32_al_pcix , 0xffff, 0x23fb, { 34, 34, 13, 13}}, - {m68k_op_move_32_al_i , 0xffff, 0x23fc, { 28, 28, 10, 10}}, - {m68k_op_move_16_aw_aw , 0xffff, 0x31f8, { 20, 20, 8, 8}}, - {m68k_op_move_16_aw_al , 0xffff, 0x31f9, { 24, 24, 8, 8}}, - {m68k_op_move_16_aw_pcdi , 0xffff, 0x31fa, { 20, 20, 9, 9}}, - {m68k_op_move_16_aw_pcix , 0xffff, 0x31fb, { 22, 22, 11, 11}}, - {m68k_op_move_16_aw_i , 0xffff, 0x31fc, { 16, 16, 6, 6}}, - {m68k_op_move_16_al_aw , 0xffff, 0x33f8, { 24, 24, 10, 10}}, - {m68k_op_move_16_al_al , 0xffff, 0x33f9, { 28, 28, 10, 10}}, - {m68k_op_move_16_al_pcdi , 0xffff, 0x33fa, { 24, 24, 11, 11}}, - {m68k_op_move_16_al_pcix , 0xffff, 0x33fb, { 26, 26, 13, 13}}, - {m68k_op_move_16_al_i , 0xffff, 0x33fc, { 20, 20, 8, 8}}, - {m68k_op_negx_8_pi7 , 0xffff, 0x401f, { 12, 12, 8, 8}}, - {m68k_op_negx_8_pd7 , 0xffff, 0x4027, { 14, 14, 9, 9}}, - {m68k_op_negx_8_aw , 0xffff, 0x4038, { 16, 16, 8, 8}}, - {m68k_op_negx_8_al , 0xffff, 0x4039, { 20, 20, 8, 8}}, - {m68k_op_negx_16_aw , 0xffff, 0x4078, { 16, 16, 8, 8}}, - {m68k_op_negx_16_al , 0xffff, 0x4079, { 20, 20, 8, 8}}, - {m68k_op_negx_32_aw , 0xffff, 0x40b8, { 24, 24, 8, 8}}, - {m68k_op_negx_32_al , 0xffff, 0x40b9, { 28, 28, 8, 8}}, - {m68k_op_move_16_frs_aw , 0xffff, 0x40f8, { 16, 16, 12, 12}}, - {m68k_op_move_16_frs_al , 0xffff, 0x40f9, { 20, 20, 12, 12}}, - {m68k_op_clr_8_pi7 , 0xffff, 0x421f, { 12, 8, 8, 8}}, - {m68k_op_clr_8_pd7 , 0xffff, 0x4227, { 14, 10, 9, 9}}, - {m68k_op_clr_8_aw , 0xffff, 0x4238, { 16, 12, 8, 8}}, - {m68k_op_clr_8_al , 0xffff, 0x4239, { 20, 14, 8, 8}}, - {m68k_op_clr_16_aw , 0xffff, 0x4278, { 16, 12, 8, 8}}, - {m68k_op_clr_16_al , 0xffff, 0x4279, { 20, 14, 8, 8}}, - {m68k_op_clr_32_aw , 0xffff, 0x42b8, { 24, 16, 8, 8}}, - {m68k_op_clr_32_al , 0xffff, 0x42b9, { 28, 20, 8, 8}}, -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_move_16_frc_aw , 0xffff, 0x42f8, { 0, 16, 8, 8}}, - {m68k_op_move_16_frc_al , 0xffff, 0x42f9, { 0, 20, 8, 8}}, -#endif - {m68k_op_neg_8_pi7 , 0xffff, 0x441f, { 12, 12, 8, 8}}, - {m68k_op_neg_8_pd7 , 0xffff, 0x4427, { 14, 14, 9, 9}}, - {m68k_op_neg_8_aw , 0xffff, 0x4438, { 16, 16, 8, 8}}, - {m68k_op_neg_8_al , 0xffff, 0x4439, { 20, 20, 8, 8}}, - {m68k_op_neg_16_aw , 0xffff, 0x4478, { 16, 16, 8, 8}}, - {m68k_op_neg_16_al , 0xffff, 0x4479, { 20, 20, 8, 8}}, - {m68k_op_neg_32_aw , 0xffff, 0x44b8, { 24, 24, 8, 8}}, - {m68k_op_neg_32_al , 0xffff, 0x44b9, { 28, 28, 8, 8}}, - {m68k_op_move_16_toc_aw , 0xffff, 0x44f8, { 20, 20, 8, 8}}, - {m68k_op_move_16_toc_al , 0xffff, 0x44f9, { 24, 24, 8, 8}}, - {m68k_op_move_16_toc_pcdi , 0xffff, 0x44fa, { 20, 20, 9, 9}}, - {m68k_op_move_16_toc_pcix , 0xffff, 0x44fb, { 22, 22, 11, 11}}, - {m68k_op_move_16_toc_i , 0xffff, 0x44fc, { 16, 16, 6, 6}}, - {m68k_op_not_8_pi7 , 0xffff, 0x461f, { 12, 12, 8, 8}}, - {m68k_op_not_8_pd7 , 0xffff, 0x4627, { 14, 14, 9, 9}}, - {m68k_op_not_8_aw , 0xffff, 0x4638, { 16, 16, 8, 8}}, - {m68k_op_not_8_al , 0xffff, 0x4639, { 20, 20, 8, 8}}, - {m68k_op_not_16_aw , 0xffff, 0x4678, { 16, 16, 8, 8}}, - {m68k_op_not_16_al , 0xffff, 0x4679, { 20, 20, 8, 8}}, - {m68k_op_not_32_aw , 0xffff, 0x46b8, { 24, 24, 8, 8}}, - {m68k_op_not_32_al , 0xffff, 0x46b9, { 28, 28, 8, 8}}, - {m68k_op_move_16_tos_aw , 0xffff, 0x46f8, { 20, 20, 12, 12}}, - {m68k_op_move_16_tos_al , 0xffff, 0x46f9, { 24, 24, 12, 12}}, - {m68k_op_move_16_tos_pcdi , 0xffff, 0x46fa, { 20, 20, 13, 13}}, - {m68k_op_move_16_tos_pcix , 0xffff, 0x46fb, { 22, 22, 15, 15}}, - {m68k_op_move_16_tos_i , 0xffff, 0x46fc, { 16, 16, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_link_32_a7 , 0xffff, 0x480f, { 0, 0, 6, 6}}, -#endif - {m68k_op_nbcd_8_pi7 , 0xffff, 0x481f, { 12, 12, 10, 10}}, - {m68k_op_nbcd_8_pd7 , 0xffff, 0x4827, { 14, 14, 11, 11}}, - {m68k_op_nbcd_8_aw , 0xffff, 0x4838, { 16, 16, 10, 10}}, - {m68k_op_nbcd_8_al , 0xffff, 0x4839, { 20, 20, 10, 10}}, - {m68k_op_pea_32_aw , 0xffff, 0x4878, { 16, 16, 9, 9}}, - {m68k_op_pea_32_al , 0xffff, 0x4879, { 20, 20, 9, 9}}, - {m68k_op_pea_32_pcdi , 0xffff, 0x487a, { 16, 16, 10, 10}}, - {m68k_op_pea_32_pcix , 0xffff, 0x487b, { 20, 20, 12, 12}}, - {m68k_op_movem_16_re_aw , 0xffff, 0x48b8, { 12, 12, 8, 8}}, - {m68k_op_movem_16_re_al , 0xffff, 0x48b9, { 16, 16, 8, 8}}, - {m68k_op_movem_32_re_aw , 0xffff, 0x48f8, { 12, 12, 8, 8}}, - {m68k_op_movem_32_re_al , 0xffff, 0x48f9, { 16, 16, 8, 8}}, - {m68k_op_tst_8_pi7 , 0xffff, 0x4a1f, { 8, 8, 6, 6}}, - {m68k_op_tst_8_pd7 , 0xffff, 0x4a27, { 10, 10, 7, 7}}, - {m68k_op_tst_8_aw , 0xffff, 0x4a38, { 12, 12, 6, 6}}, - {m68k_op_tst_8_al , 0xffff, 0x4a39, { 16, 16, 6, 6}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_tst_8_pcdi , 0xffff, 0x4a3a, { 0, 0, 7, 7}}, - {m68k_op_tst_8_pcix , 0xffff, 0x4a3b, { 0, 0, 9, 9}}, - {m68k_op_tst_8_i , 0xffff, 0x4a3c, { 0, 0, 6, 6}}, -#endif - {m68k_op_tst_16_aw , 0xffff, 0x4a78, { 12, 12, 6, 6}}, - {m68k_op_tst_16_al , 0xffff, 0x4a79, { 16, 16, 6, 6}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_tst_16_pcdi , 0xffff, 0x4a7a, { 0, 0, 7, 7}}, - {m68k_op_tst_16_pcix , 0xffff, 0x4a7b, { 0, 0, 9, 9}}, - {m68k_op_tst_16_i , 0xffff, 0x4a7c, { 0, 0, 6, 6}}, -#endif - {m68k_op_tst_32_aw , 0xffff, 0x4ab8, { 16, 16, 6, 6}}, - {m68k_op_tst_32_al , 0xffff, 0x4ab9, { 20, 20, 6, 6}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_tst_32_pcdi , 0xffff, 0x4aba, { 0, 0, 7, 7}}, - {m68k_op_tst_32_pcix , 0xffff, 0x4abb, { 0, 0, 9, 9}}, - {m68k_op_tst_32_i , 0xffff, 0x4abc, { 0, 0, 6, 6}}, -#endif - {m68k_op_tas_8_pi7 , 0xffff, 0x4adf, { 18, 18, 16, 16}}, - {m68k_op_tas_8_pd7 , 0xffff, 0x4ae7, { 20, 20, 17, 17}}, - {m68k_op_tas_8_aw , 0xffff, 0x4af8, { 22, 22, 16, 16}}, - {m68k_op_tas_8_al , 0xffff, 0x4af9, { 26, 26, 16, 16}}, - {m68k_op_illegal , 0xffff, 0x4afc, { 4, 4, 4, 4}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_mull_32_aw , 0xffff, 0x4c38, { 0, 0, 47, 47}}, - {m68k_op_mull_32_al , 0xffff, 0x4c39, { 0, 0, 47, 47}}, - {m68k_op_mull_32_pcdi , 0xffff, 0x4c3a, { 0, 0, 48, 48}}, - {m68k_op_mull_32_pcix , 0xffff, 0x4c3b, { 0, 0, 50, 50}}, - {m68k_op_mull_32_i , 0xffff, 0x4c3c, { 0, 0, 47, 47}}, - {m68k_op_divl_32_aw , 0xffff, 0x4c78, { 0, 0, 88, 88}}, - {m68k_op_divl_32_al , 0xffff, 0x4c79, { 0, 0, 88, 88}}, - {m68k_op_divl_32_pcdi , 0xffff, 0x4c7a, { 0, 0, 89, 89}}, - {m68k_op_divl_32_pcix , 0xffff, 0x4c7b, { 0, 0, 91, 91}}, - {m68k_op_divl_32_i , 0xffff, 0x4c7c, { 0, 0, 88, 88}}, -#endif - {m68k_op_movem_16_er_aw , 0xffff, 0x4cb8, { 16, 16, 12, 12}}, - {m68k_op_movem_16_er_al , 0xffff, 0x4cb9, { 20, 20, 12, 12}}, - {m68k_op_movem_16_er_pcdi , 0xffff, 0x4cba, { 16, 16, 9, 9}}, - {m68k_op_movem_16_er_pcix , 0xffff, 0x4cbb, { 18, 18, 11, 11}}, - {m68k_op_movem_32_er_aw , 0xffff, 0x4cf8, { 16, 16, 12, 12}}, - {m68k_op_movem_32_er_al , 0xffff, 0x4cf9, { 20, 20, 12, 12}}, - {m68k_op_movem_32_er_pcdi , 0xffff, 0x4cfa, { 16, 16, 9, 9}}, - {m68k_op_movem_32_er_pcix , 0xffff, 0x4cfb, { 18, 18, 11, 11}}, - {m68k_op_link_16_a7 , 0xffff, 0x4e57, { 16, 16, 5, 5}}, - {m68k_op_unlk_32_a7 , 0xffff, 0x4e5f, { 12, 12, 6, 6}}, - {m68k_op_reset , 0xffff, 0x4e70, { 0, 0, 0, 0}}, - {m68k_op_nop , 0xffff, 0x4e71, { 4, 4, 2, 2}}, - {m68k_op_stop , 0xffff, 0x4e72, { 4, 4, 8, 8}}, - {m68k_op_rte_32 , 0xffff, 0x4e73, { 20, 24, 20, 20}}, -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_rtd_32 , 0xffff, 0x4e74, { 0, 16, 10, 10}}, -#endif - {m68k_op_rts_32 , 0xffff, 0x4e75, { 16, 16, 10, 10}}, - {m68k_op_trapv , 0xffff, 0x4e76, { 4, 4, 4, 4}}, - {m68k_op_rtr_32 , 0xffff, 0x4e77, { 20, 20, 14, 14}}, -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_movec_32_cr , 0xffff, 0x4e7a, { 0, 12, 6, 6}}, - {m68k_op_movec_32_rc , 0xffff, 0x4e7b, { 0, 10, 12, 12}}, -#endif - {m68k_op_jsr_32_aw , 0xffff, 0x4eb8, { 18, 18, 4, 4}}, - {m68k_op_jsr_32_al , 0xffff, 0x4eb9, { 20, 20, 4, 4}}, - {m68k_op_jsr_32_pcdi , 0xffff, 0x4eba, { 18, 18, 5, 5}}, - {m68k_op_jsr_32_pcix , 0xffff, 0x4ebb, { 22, 22, 7, 7}}, - {m68k_op_jmp_32_aw , 0xffff, 0x4ef8, { 10, 10, 4, 4}}, - {m68k_op_jmp_32_al , 0xffff, 0x4ef9, { 12, 12, 4, 4}}, - {m68k_op_jmp_32_pcdi , 0xffff, 0x4efa, { 10, 10, 5, 5}}, - {m68k_op_jmp_32_pcix , 0xffff, 0x4efb, { 14, 14, 7, 7}}, - {m68k_op_st_8_pi7 , 0xffff, 0x50df, { 12, 12, 10, 10}}, - {m68k_op_st_8_pd7 , 0xffff, 0x50e7, { 14, 14, 11, 11}}, - {m68k_op_st_8_aw , 0xffff, 0x50f8, { 16, 16, 10, 10}}, - {m68k_op_st_8_al , 0xffff, 0x50f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapt_16 , 0xffff, 0x50fa, { 0, 0, 6, 6}}, - {m68k_op_trapt_32 , 0xffff, 0x50fb, { 0, 0, 8, 8}}, - {m68k_op_trapt , 0xffff, 0x50fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_sf_8_pi7 , 0xffff, 0x51df, { 12, 12, 10, 10}}, - {m68k_op_sf_8_pd7 , 0xffff, 0x51e7, { 14, 14, 11, 11}}, - {m68k_op_sf_8_aw , 0xffff, 0x51f8, { 16, 16, 10, 10}}, - {m68k_op_sf_8_al , 0xffff, 0x51f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapf_16 , 0xffff, 0x51fa, { 0, 0, 6, 6}}, - {m68k_op_trapf_32 , 0xffff, 0x51fb, { 0, 0, 8, 8}}, - {m68k_op_trapf , 0xffff, 0x51fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_shi_8_pi7 , 0xffff, 0x52df, { 12, 12, 10, 10}}, - {m68k_op_shi_8_pd7 , 0xffff, 0x52e7, { 14, 14, 11, 11}}, - {m68k_op_shi_8_aw , 0xffff, 0x52f8, { 16, 16, 10, 10}}, - {m68k_op_shi_8_al , 0xffff, 0x52f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_traphi_16 , 0xffff, 0x52fa, { 0, 0, 6, 6}}, - {m68k_op_traphi_32 , 0xffff, 0x52fb, { 0, 0, 8, 8}}, - {m68k_op_traphi , 0xffff, 0x52fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_sls_8_pi7 , 0xffff, 0x53df, { 12, 12, 10, 10}}, - {m68k_op_sls_8_pd7 , 0xffff, 0x53e7, { 14, 14, 11, 11}}, - {m68k_op_sls_8_aw , 0xffff, 0x53f8, { 16, 16, 10, 10}}, - {m68k_op_sls_8_al , 0xffff, 0x53f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapls_16 , 0xffff, 0x53fa, { 0, 0, 6, 6}}, - {m68k_op_trapls_32 , 0xffff, 0x53fb, { 0, 0, 8, 8}}, - {m68k_op_trapls , 0xffff, 0x53fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_scc_8_pi7 , 0xffff, 0x54df, { 12, 12, 10, 10}}, - {m68k_op_scc_8_pd7 , 0xffff, 0x54e7, { 14, 14, 11, 11}}, - {m68k_op_scc_8_aw , 0xffff, 0x54f8, { 16, 16, 10, 10}}, - {m68k_op_scc_8_al , 0xffff, 0x54f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapcc_16 , 0xffff, 0x54fa, { 0, 0, 6, 6}}, - {m68k_op_trapcc_32 , 0xffff, 0x54fb, { 0, 0, 8, 8}}, - {m68k_op_trapcc , 0xffff, 0x54fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_scs_8_pi7 , 0xffff, 0x55df, { 12, 12, 10, 10}}, - {m68k_op_scs_8_pd7 , 0xffff, 0x55e7, { 14, 14, 11, 11}}, - {m68k_op_scs_8_aw , 0xffff, 0x55f8, { 16, 16, 10, 10}}, - {m68k_op_scs_8_al , 0xffff, 0x55f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapcs_16 , 0xffff, 0x55fa, { 0, 0, 6, 6}}, - {m68k_op_trapcs_32 , 0xffff, 0x55fb, { 0, 0, 8, 8}}, - {m68k_op_trapcs , 0xffff, 0x55fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_sne_8_pi7 , 0xffff, 0x56df, { 12, 12, 10, 10}}, - {m68k_op_sne_8_pd7 , 0xffff, 0x56e7, { 14, 14, 11, 11}}, - {m68k_op_sne_8_aw , 0xffff, 0x56f8, { 16, 16, 10, 10}}, - {m68k_op_sne_8_al , 0xffff, 0x56f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapne_16 , 0xffff, 0x56fa, { 0, 0, 6, 6}}, - {m68k_op_trapne_32 , 0xffff, 0x56fb, { 0, 0, 8, 8}}, - {m68k_op_trapne , 0xffff, 0x56fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_seq_8_pi7 , 0xffff, 0x57df, { 12, 12, 10, 10}}, - {m68k_op_seq_8_pd7 , 0xffff, 0x57e7, { 14, 14, 11, 11}}, - {m68k_op_seq_8_aw , 0xffff, 0x57f8, { 16, 16, 10, 10}}, - {m68k_op_seq_8_al , 0xffff, 0x57f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapeq_16 , 0xffff, 0x57fa, { 0, 0, 6, 6}}, - {m68k_op_trapeq_32 , 0xffff, 0x57fb, { 0, 0, 8, 8}}, - {m68k_op_trapeq , 0xffff, 0x57fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_svc_8_pi7 , 0xffff, 0x58df, { 12, 12, 10, 10}}, - {m68k_op_svc_8_pd7 , 0xffff, 0x58e7, { 14, 14, 11, 11}}, - {m68k_op_svc_8_aw , 0xffff, 0x58f8, { 16, 16, 10, 10}}, - {m68k_op_svc_8_al , 0xffff, 0x58f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapvc_16 , 0xffff, 0x58fa, { 0, 0, 6, 6}}, - {m68k_op_trapvc_32 , 0xffff, 0x58fb, { 0, 0, 8, 8}}, - {m68k_op_trapvc , 0xffff, 0x58fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_svs_8_pi7 , 0xffff, 0x59df, { 12, 12, 10, 10}}, - {m68k_op_svs_8_pd7 , 0xffff, 0x59e7, { 14, 14, 11, 11}}, - {m68k_op_svs_8_aw , 0xffff, 0x59f8, { 16, 16, 10, 10}}, - {m68k_op_svs_8_al , 0xffff, 0x59f9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapvs_16 , 0xffff, 0x59fa, { 0, 0, 6, 6}}, - {m68k_op_trapvs_32 , 0xffff, 0x59fb, { 0, 0, 8, 8}}, - {m68k_op_trapvs , 0xffff, 0x59fc, { 0, 0, 4, 4}}, -#endif - {m68k_op_spl_8_pi7 , 0xffff, 0x5adf, { 12, 12, 10, 10}}, - {m68k_op_spl_8_pd7 , 0xffff, 0x5ae7, { 14, 14, 11, 11}}, - {m68k_op_spl_8_aw , 0xffff, 0x5af8, { 16, 16, 10, 10}}, - {m68k_op_spl_8_al , 0xffff, 0x5af9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trappl_16 , 0xffff, 0x5afa, { 0, 0, 6, 6}}, - {m68k_op_trappl_32 , 0xffff, 0x5afb, { 0, 0, 8, 8}}, - {m68k_op_trappl , 0xffff, 0x5afc, { 0, 0, 4, 4}}, -#endif - {m68k_op_smi_8_pi7 , 0xffff, 0x5bdf, { 12, 12, 10, 10}}, - {m68k_op_smi_8_pd7 , 0xffff, 0x5be7, { 14, 14, 11, 11}}, - {m68k_op_smi_8_aw , 0xffff, 0x5bf8, { 16, 16, 10, 10}}, - {m68k_op_smi_8_al , 0xffff, 0x5bf9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapmi_16 , 0xffff, 0x5bfa, { 0, 0, 6, 6}}, - {m68k_op_trapmi_32 , 0xffff, 0x5bfb, { 0, 0, 8, 8}}, - {m68k_op_trapmi , 0xffff, 0x5bfc, { 0, 0, 4, 4}}, -#endif - {m68k_op_sge_8_pi7 , 0xffff, 0x5cdf, { 12, 12, 10, 10}}, - {m68k_op_sge_8_pd7 , 0xffff, 0x5ce7, { 14, 14, 11, 11}}, - {m68k_op_sge_8_aw , 0xffff, 0x5cf8, { 16, 16, 10, 10}}, - {m68k_op_sge_8_al , 0xffff, 0x5cf9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapge_16 , 0xffff, 0x5cfa, { 0, 0, 6, 6}}, - {m68k_op_trapge_32 , 0xffff, 0x5cfb, { 0, 0, 8, 8}}, - {m68k_op_trapge , 0xffff, 0x5cfc, { 0, 0, 4, 4}}, -#endif - {m68k_op_slt_8_pi7 , 0xffff, 0x5ddf, { 12, 12, 10, 10}}, - {m68k_op_slt_8_pd7 , 0xffff, 0x5de7, { 14, 14, 11, 11}}, - {m68k_op_slt_8_aw , 0xffff, 0x5df8, { 16, 16, 10, 10}}, - {m68k_op_slt_8_al , 0xffff, 0x5df9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_traplt_16 , 0xffff, 0x5dfa, { 0, 0, 6, 6}}, - {m68k_op_traplt_32 , 0xffff, 0x5dfb, { 0, 0, 8, 8}}, - {m68k_op_traplt , 0xffff, 0x5dfc, { 0, 0, 4, 4}}, -#endif - {m68k_op_sgt_8_pi7 , 0xffff, 0x5edf, { 12, 12, 10, 10}}, - {m68k_op_sgt_8_pd7 , 0xffff, 0x5ee7, { 14, 14, 11, 11}}, - {m68k_op_sgt_8_aw , 0xffff, 0x5ef8, { 16, 16, 10, 10}}, - {m68k_op_sgt_8_al , 0xffff, 0x5ef9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_trapgt_16 , 0xffff, 0x5efa, { 0, 0, 6, 6}}, - {m68k_op_trapgt_32 , 0xffff, 0x5efb, { 0, 0, 8, 8}}, - {m68k_op_trapgt , 0xffff, 0x5efc, { 0, 0, 4, 4}}, -#endif - {m68k_op_sle_8_pi7 , 0xffff, 0x5fdf, { 12, 12, 10, 10}}, - {m68k_op_sle_8_pd7 , 0xffff, 0x5fe7, { 14, 14, 11, 11}}, - {m68k_op_sle_8_aw , 0xffff, 0x5ff8, { 16, 16, 10, 10}}, - {m68k_op_sle_8_al , 0xffff, 0x5ff9, { 20, 20, 10, 10}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_traple_16 , 0xffff, 0x5ffa, { 0, 0, 6, 6}}, - {m68k_op_traple_32 , 0xffff, 0x5ffb, { 0, 0, 8, 8}}, - {m68k_op_traple , 0xffff, 0x5ffc, { 0, 0, 4, 4}}, -#endif - {m68k_op_bra_16 , 0xffff, 0x6000, { 10, 10, 10, 10}}, - {m68k_op_bra_32 , 0xffff, 0x60ff, { 10, 10, 10, 10}}, - {m68k_op_bsr_16 , 0xffff, 0x6100, { 18, 18, 7, 7}}, - {m68k_op_bsr_32 , 0xffff, 0x61ff, { 18, 18, 7, 7}}, - {m68k_op_bhi_16 , 0xffff, 0x6200, { 10, 10, 6, 6}}, - {m68k_op_bhi_32 , 0xffff, 0x62ff, { 10, 10, 6, 6}}, - {m68k_op_bls_16 , 0xffff, 0x6300, { 10, 10, 6, 6}}, - {m68k_op_bls_32 , 0xffff, 0x63ff, { 10, 10, 6, 6}}, - {m68k_op_bcc_16 , 0xffff, 0x6400, { 10, 10, 6, 6}}, - {m68k_op_bcc_32 , 0xffff, 0x64ff, { 10, 10, 6, 6}}, - {m68k_op_bcs_16 , 0xffff, 0x6500, { 10, 10, 6, 6}}, - {m68k_op_bcs_32 , 0xffff, 0x65ff, { 10, 10, 6, 6}}, - {m68k_op_bne_16 , 0xffff, 0x6600, { 10, 10, 6, 6}}, - {m68k_op_bne_32 , 0xffff, 0x66ff, { 10, 10, 6, 6}}, - {m68k_op_beq_16 , 0xffff, 0x6700, { 10, 10, 6, 6}}, - {m68k_op_beq_32 , 0xffff, 0x67ff, { 10, 10, 6, 6}}, - {m68k_op_bvc_16 , 0xffff, 0x6800, { 10, 10, 6, 6}}, - {m68k_op_bvc_32 , 0xffff, 0x68ff, { 10, 10, 6, 6}}, - {m68k_op_bvs_16 , 0xffff, 0x6900, { 10, 10, 6, 6}}, - {m68k_op_bvs_32 , 0xffff, 0x69ff, { 10, 10, 6, 6}}, - {m68k_op_bpl_16 , 0xffff, 0x6a00, { 10, 10, 6, 6}}, - {m68k_op_bpl_32 , 0xffff, 0x6aff, { 10, 10, 6, 6}}, - {m68k_op_bmi_16 , 0xffff, 0x6b00, { 10, 10, 6, 6}}, - {m68k_op_bmi_32 , 0xffff, 0x6bff, { 10, 10, 6, 6}}, - {m68k_op_bge_16 , 0xffff, 0x6c00, { 10, 10, 6, 6}}, - {m68k_op_bge_32 , 0xffff, 0x6cff, { 10, 10, 6, 6}}, - {m68k_op_blt_16 , 0xffff, 0x6d00, { 10, 10, 6, 6}}, - {m68k_op_blt_32 , 0xffff, 0x6dff, { 10, 10, 6, 6}}, - {m68k_op_bgt_16 , 0xffff, 0x6e00, { 10, 10, 6, 6}}, - {m68k_op_bgt_32 , 0xffff, 0x6eff, { 10, 10, 6, 6}}, - {m68k_op_ble_16 , 0xffff, 0x6f00, { 10, 10, 6, 6}}, - {m68k_op_ble_32 , 0xffff, 0x6fff, { 10, 10, 6, 6}}, - {m68k_op_sbcd_8_mm_axy7 , 0xffff, 0x8f0f, { 18, 18, 16, 16}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_pack_16_mm_axy7 , 0xffff, 0x8f4f, { 0, 0, 13, 13}}, - {m68k_op_unpk_16_mm_axy7 , 0xffff, 0x8f8f, { 0, 0, 13, 13}}, -#endif - {m68k_op_subx_8_mm_axy7 , 0xffff, 0x9f0f, { 18, 18, 12, 12}}, - {m68k_op_cmpm_8_axy7 , 0xffff, 0xbf0f, { 12, 12, 9, 9}}, - {m68k_op_abcd_8_mm_axy7 , 0xffff, 0xcf0f, { 18, 18, 16, 16}}, - {m68k_op_addx_8_mm_axy7 , 0xffff, 0xdf0f, { 18, 18, 12, 12}}, - {m68k_op_asr_16_aw , 0xffff, 0xe0f8, { 16, 16, 9, 9}}, - {m68k_op_asr_16_al , 0xffff, 0xe0f9, { 20, 20, 9, 9}}, - {m68k_op_asl_16_aw , 0xffff, 0xe1f8, { 16, 16, 10, 10}}, - {m68k_op_asl_16_al , 0xffff, 0xe1f9, { 20, 20, 10, 10}}, - {m68k_op_lsr_16_aw , 0xffff, 0xe2f8, { 16, 16, 9, 9}}, - {m68k_op_lsr_16_al , 0xffff, 0xe2f9, { 20, 20, 9, 9}}, - {m68k_op_lsl_16_aw , 0xffff, 0xe3f8, { 16, 16, 9, 9}}, - {m68k_op_lsl_16_al , 0xffff, 0xe3f9, { 20, 20, 9, 9}}, - {m68k_op_roxr_16_aw , 0xffff, 0xe4f8, { 16, 16, 9, 9}}, - {m68k_op_roxr_16_al , 0xffff, 0xe4f9, { 20, 20, 9, 9}}, - {m68k_op_roxl_16_aw , 0xffff, 0xe5f8, { 16, 16, 9, 9}}, - {m68k_op_roxl_16_al , 0xffff, 0xe5f9, { 20, 20, 9, 9}}, - {m68k_op_ror_16_aw , 0xffff, 0xe6f8, { 16, 16, 11, 11}}, - {m68k_op_ror_16_al , 0xffff, 0xe6f9, { 20, 20, 11, 11}}, - {m68k_op_rol_16_aw , 0xffff, 0xe7f8, { 16, 16, 11, 11}}, - {m68k_op_rol_16_al , 0xffff, 0xe7f9, { 20, 20, 11, 11}}, -#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 - {m68k_op_bftst_32_aw , 0xffff, 0xe8f8, { 0, 0, 17, 17}}, - {m68k_op_bftst_32_al , 0xffff, 0xe8f9, { 0, 0, 17, 17}}, - {m68k_op_bftst_32_pcdi , 0xffff, 0xe8fa, { 0, 0, 18, 18}}, - {m68k_op_bftst_32_pcix , 0xffff, 0xe8fb, { 0, 0, 20, 20}}, - {m68k_op_bfextu_32_aw , 0xffff, 0xe9f8, { 0, 0, 19, 19}}, - {m68k_op_bfextu_32_al , 0xffff, 0xe9f9, { 0, 0, 19, 19}}, - {m68k_op_bfextu_32_pcdi , 0xffff, 0xe9fa, { 0, 0, 20, 20}}, - {m68k_op_bfextu_32_pcix , 0xffff, 0xe9fb, { 0, 0, 22, 22}}, - {m68k_op_bfchg_32_aw , 0xffff, 0xeaf8, { 0, 0, 24, 24}}, - {m68k_op_bfchg_32_al , 0xffff, 0xeaf9, { 0, 0, 24, 24}}, - {m68k_op_bfexts_32_aw , 0xffff, 0xebf8, { 0, 0, 19, 19}}, - {m68k_op_bfexts_32_al , 0xffff, 0xebf9, { 0, 0, 19, 19}}, - {m68k_op_bfexts_32_pcdi , 0xffff, 0xebfa, { 0, 0, 20, 20}}, - {m68k_op_bfexts_32_pcix , 0xffff, 0xebfb, { 0, 0, 22, 22}}, - {m68k_op_bfclr_32_aw , 0xffff, 0xecf8, { 0, 0, 24, 24}}, - {m68k_op_bfclr_32_al , 0xffff, 0xecf9, { 0, 0, 24, 24}}, - {m68k_op_bfffo_32_aw , 0xffff, 0xedf8, { 0, 0, 32, 32}}, - {m68k_op_bfffo_32_al , 0xffff, 0xedf9, { 0, 0, 32, 32}}, - {m68k_op_bfffo_32_pcdi , 0xffff, 0xedfa, { 0, 0, 33, 33}}, - {m68k_op_bfffo_32_pcix , 0xffff, 0xedfb, { 0, 0, 35, 35}}, - {m68k_op_bfset_32_aw , 0xffff, 0xeef8, { 0, 0, 24, 24}}, - {m68k_op_bfset_32_al , 0xffff, 0xeef9, { 0, 0, 24, 24}}, - {m68k_op_bfins_32_aw , 0xffff, 0xeff8, { 0, 0, 21, 21}}, - {m68k_op_bfins_32_al , 0xffff, 0xeff9, { 0, 0, 21, 21}}, -#endif -#if M68K_EMULATE_040 - {m68k_op_pflush_32 , 0xffff, 0xf518, { 0, 0, 0, 4}}, -#endif - {0, 0, 0, {0, 0, 0, 0}} -}; - - -/* Build the opcode handler jump table */ -void m68ki_build_opcode_table(void) -{ - const opcode_handler_struct *ostruct; - int instr; - int i; - int j; - int k; - - for(i = 0; i < 256; i++) - for(k=0;kmask != 0xff00) - { - for(i = 0;i < 0x10000;i++) - { - if((i & ostruct->mask) == ostruct->match) - { - m68ki_instruction_jump_table[i] = ostruct->opcode_handler; - for(k=0;kcycles[k]*7; - } - } - ostruct++; - } - while(ostruct->mask == 0xff00) - { - for(i = 0;i <= 0xff;i++) - { - m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; - for(k=0;kmatch | i] = ostruct->cycles[k]*7; - } - ostruct++; - } - while(ostruct->mask == 0xf1f8) - { - for(i = 0;i < 8;i++) - { - for(j = 0;j < 8;j++) - { - instr = ostruct->match | (i << 9) | j; - m68ki_instruction_jump_table[instr] = ostruct->opcode_handler; - for(k=0;kcycles[k]*7; - } - } - ostruct++; - } - while(ostruct->mask == 0xfff0) - { - for(i = 0;i <= 0x0f;i++) - { - m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; - for(k=0;kmatch | i] = ostruct->cycles[k]*7; - } - ostruct++; - } - while(ostruct->mask == 0xf1ff) - { - for(i = 0;i <= 0x07;i++) - { - m68ki_instruction_jump_table[ostruct->match | (i << 9)] = ostruct->opcode_handler; - for(k=0;kmatch | (i << 9)] = ostruct->cycles[k]*7; - } - ostruct++; - } - while(ostruct->mask == 0xfff8) - { - for(i = 0;i <= 0x07;i++) - { - m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; - for(k=0;kmatch | i] = ostruct->cycles[k]*7; - } - ostruct++; - } - while(ostruct->mask == 0xffff) - { - m68ki_instruction_jump_table[ostruct->match] = ostruct->opcode_handler; - for(k=0;kmatch] = ostruct->cycles[k]*7; - ostruct++; - } -} - - -/* ======================================================================== */ -/* ============================== END OF FILE ============================= */ -/* ======================================================================== */ - - diff --git a/source/m68k/m68kops.h b/source/m68k/m68kops.h index 0d7ae31..45c273b 100644 --- a/source/m68k/m68kops.h +++ b/source/m68k/m68kops.h @@ -1,27 +1,25428 @@ -#ifndef M68KOPS__HEADER -#define M68KOPS__HEADER + +#include /* ======================================================================== */ -/* ============================ OPCODE HANDLERS =========================== */ +/* ============== CYCLE-ACCURATE DIV/MUL EXECUTION ======================== */ /* ======================================================================== */ -#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040 -#define NUM_CPU_TYPES 4 +INLINE void UseDivuCycles(uint32 dst, uint32 src) +{ + int i; + + /* minimum cycle time */ + uint mcycles = 38 * 7; + + /* 16-bit divisor */ + src <<= 16; + + /* 16-bit dividend */ + for (i=0; i<15; i++) + { + /* check if carry bit set */ + if ((sint32) dst < 0) + { + /* shift dividend and apply divisor */ + dst <<= 1; + dst -= src; + } + else + { + /* shift dividend and add two cycles */ + dst <<= 1; + mcycles += (2 * 7); + + if (dst >= src) + { + /* apply divisor and remove one cycle */ + dst -= src; + mcycles -= 7; + } + } + } + + USE_CYCLES(mcycles << 1); +} + +INLINE void UseDivsCycles(sint32 dst, sint16 src) +{ + /* minimum cycle time */ + uint mcycles = 6 * 7; + + /* negative dividend */ + if (dst < 0) mcycles += 7; + + if ((abs(dst) >> 16) < abs(src)) + { + /* absolute quotient */ + uint32 quotient = abs(dst) / abs(src); + + /* add default cycle time */ + mcycles += (55 * 7); + + /* positive divisor */ + if (src >= 0) + { + /* check dividend sign */ + if (dst >= 0) mcycles -= 7; + else mcycles += 7; + } + + /* check higher 15-bits of quotient */ + int i; + for (i=0; i<15; i++) + { + quotient >>= 1; + if (!(quotient & 1)) mcycles += 7; + } + } + else + { + /* absolute overflow */ + mcycles += (2 * 7); + } + + USE_CYCLES(mcycles << 1); +} + +INLINE void UseMuluCycles(uint16 src) +{ + /* minimum cycle time */ + uint mcycles = 38 * 7; + + /* count number of bits set to 1 */ + while (src) + { + if (src & 1) mcycles += (7 * 2); + src >>= 1; + } + + /* 38 + 2*N */ + USE_CYCLES(mcycles); +} + +INLINE void UseMulsCycles(sint16 src) +{ + /* minimum cycle time */ + uint mcycles = 38 * 7; + + /* detect 01 or 10 patterns */ + sint32 tmp = src << 1; + tmp = (tmp ^ src) & 0xFFFF; + + /* count number of bits set to 1 */ + while (tmp) + { + if (tmp & 1) mcycles += (7 * 2); + tmp >>= 1; + } + + /* 38 + 2*N */ + USE_CYCLES(mcycles); +} + + +/* ======================================================================== */ +/* ========================= INSTRUCTION HANDLERS ========================= */ +/* ======================================================================== */ + + +static void m68k_op_1010(void) +{ + m68ki_exception_1010(); +} + + +static void m68k_op_1111(void) +{ + m68ki_exception_1111(); +} + + +static void m68k_op_abcd_8_rr(void) +{ + uint* r_dst = &DX; + uint src = DY; + uint dst = *r_dst; + uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); + + FLAG_V = ~res; /* Undefined V behavior */ + + if(res > 9) + res += 6; + res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); + FLAG_X = FLAG_C = (res > 0x99) << 8; + if(FLAG_C) + res -= 0xa0; + + FLAG_V &= res; /* Undefined V behavior part II */ + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; +} + + +static void m68k_op_abcd_8_mm_ax7(void) +{ + uint src = OPER_AY_PD_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); + + FLAG_V = ~res; /* Undefined V behavior */ + + if(res > 9) + res += 6; + res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); + FLAG_X = FLAG_C = (res > 0x99) << 8; + if(FLAG_C) + res -= 0xa0; + + FLAG_V &= res; /* Undefined V behavior part II */ + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_abcd_8_mm_ay7(void) +{ + uint src = OPER_A7_PD_8(); + uint ea = EA_AX_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); + + FLAG_V = ~res; /* Undefined V behavior */ + + if(res > 9) + res += 6; + res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); + FLAG_X = FLAG_C = (res > 0x99) << 8; + if(FLAG_C) + res -= 0xa0; + + FLAG_V &= res; /* Undefined V behavior part II */ + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_abcd_8_mm_axy7(void) +{ + uint src = OPER_A7_PD_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); + + FLAG_V = ~res; /* Undefined V behavior */ + + if(res > 9) + res += 6; + res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); + FLAG_X = FLAG_C = (res > 0x99) << 8; + if(FLAG_C) + res -= 0xa0; + + FLAG_V &= res; /* Undefined V behavior part II */ + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_abcd_8_mm(void) +{ + uint src = OPER_AY_PD_8(); + uint ea = EA_AX_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1(); + + FLAG_V = ~res; /* Undefined V behavior */ + + if(res > 9) + res += 6; + res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst); + FLAG_X = FLAG_C = (res > 0x99) << 8; + if(FLAG_C) + res -= 0xa0; + + FLAG_V &= res; /* Undefined V behavior part II */ + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_add_8_er_d(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_8(DY); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_ai(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_AI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_pi(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_pi7(void) +{ + uint* r_dst = &DX; + uint src = OPER_A7_PI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_pd(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PD_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_pd7(void) +{ + uint* r_dst = &DX; + uint src = OPER_A7_PD_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_di(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_DI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_ix(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_IX_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_aw(void) +{ + uint* r_dst = &DX; + uint src = OPER_AW_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_al(void) +{ + uint* r_dst = &DX; + uint src = OPER_AL_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_pcdi(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCDI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_pcix(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCIX_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_8_er_i(void) +{ + uint* r_dst = &DX; + uint src = OPER_I_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_d(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_16(DY); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_a(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_16(AY); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_ai(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_AI_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_pi(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PI_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_pd(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PD_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_di(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_DI_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_ix(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_IX_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_aw(void) +{ + uint* r_dst = &DX; + uint src = OPER_AW_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_al(void) +{ + uint* r_dst = &DX; + uint src = OPER_AL_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_pcdi(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCDI_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_pcix(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCIX_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_16_er_i(void) +{ + uint* r_dst = &DX; + uint src = OPER_I_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_add_32_er_d(void) +{ + uint* r_dst = &DX; + uint src = DY; + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_a(void) +{ + uint* r_dst = &DX; + uint src = AY; + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_ai(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_AI_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_pi(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PI_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_pd(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PD_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_di(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_DI_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_ix(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_IX_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_aw(void) +{ + uint* r_dst = &DX; + uint src = OPER_AW_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_al(void) +{ + uint* r_dst = &DX; + uint src = OPER_AL_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_pcdi(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCDI_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_pcix(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCIX_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_32_er_i(void) +{ + uint* r_dst = &DX; + uint src = OPER_I_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_add_8_re_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_8_re_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_8_re_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_8_re_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_8_re_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_8_re_di(void) +{ + uint ea = EA_AY_DI_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_8_re_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_8_re_aw(void) +{ + uint ea = EA_AW_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_8_re_al(void) +{ + uint ea = EA_AL_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_add_16_re_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_add_16_re_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_add_16_re_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_add_16_re_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_add_16_re_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_add_16_re_aw(void) +{ + uint ea = EA_AW_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_add_16_re_al(void) +{ + uint ea = EA_AL_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_add_32_re_ai(void) +{ + uint ea = EA_AY_AI_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_add_32_re_pi(void) +{ + uint ea = EA_AY_PI_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_add_32_re_pd(void) +{ + uint ea = EA_AY_PD_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_add_32_re_di(void) +{ + uint ea = EA_AY_DI_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_add_32_re_ix(void) +{ + uint ea = EA_AY_IX_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_add_32_re_aw(void) +{ + uint ea = EA_AW_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_add_32_re_al(void) +{ + uint ea = EA_AL_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_adda_16_d(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(DY)); +} + + +static void m68k_op_adda_16_a(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + MAKE_INT_16(AY)); +} + + +static void m68k_op_adda_16_ai(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_AI_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_pi(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_PI_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_pd(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_PD_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_di(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_DI_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_ix(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_IX_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_aw(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AW_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_al(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AL_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_pcdi(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_PCDI_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_pcix(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_PCIX_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_16_i(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_I_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + src); +} + + +static void m68k_op_adda_32_d(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + DY); +} + + +static void m68k_op_adda_32_a(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + AY); +} + + +static void m68k_op_adda_32_ai(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_AY_AI_32() + *r_dst); +} + + +static void m68k_op_adda_32_pi(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_AY_PI_32() + *r_dst); +} + + +static void m68k_op_adda_32_pd(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_AY_PD_32() + *r_dst); +} + + +static void m68k_op_adda_32_di(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_AY_DI_32() + *r_dst); +} + + +static void m68k_op_adda_32_ix(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_AY_IX_32() + *r_dst); +} + + +static void m68k_op_adda_32_aw(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_AW_32() + *r_dst); +} + + +static void m68k_op_adda_32_al(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_AL_32() + *r_dst); +} + + +static void m68k_op_adda_32_pcdi(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_PCDI_32() + *r_dst); +} + + +static void m68k_op_adda_32_pcix(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_PCIX_32() + *r_dst); +} + + +static void m68k_op_adda_32_i(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(OPER_I_32() + *r_dst); +} + + +static void m68k_op_addi_8_d(void) +{ + uint* r_dst = &DY; + uint src = OPER_I_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_addi_8_ai(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_AI_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_8_pi(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_8_pi7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_8_pd(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_8_pd7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_8_di(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_DI_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_8_ix(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_IX_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_8_aw(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AW_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_8_al(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AL_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addi_16_d(void) +{ + uint* r_dst = &DY; + uint src = OPER_I_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_addi_16_ai(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_AI_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addi_16_pi(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PI_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addi_16_pd(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PD_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addi_16_di(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_DI_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addi_16_ix(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_IX_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addi_16_aw(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AW_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addi_16_al(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AL_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addi_32_d(void) +{ + uint* r_dst = &DY; + uint src = OPER_I_32(); + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_addi_32_ai(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_AI_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addi_32_pi(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PI_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addi_32_pd(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PD_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addi_32_di(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_DI_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addi_32_ix(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_IX_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addi_32_aw(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AW_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addi_32_al(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AL_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_d(void) +{ + uint* r_dst = &DY; + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_addq_8_ai(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_AI_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_pi(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_pi7(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_A7_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_pd(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_pd7(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_di(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_DI_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_ix(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_IX_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_aw(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AW_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_8_al(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AL_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst; + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_addq_16_d(void) +{ + uint* r_dst = &DY; + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_addq_16_a(void) +{ + uint* r_dst = &AY; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + (((REG_IR >> 9) - 1) & 7) + 1); +} + + +static void m68k_op_addq_16_ai(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_AI_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addq_16_pi(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PI_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addq_16_pd(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PD_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addq_16_di(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_DI_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addq_16_ix(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_IX_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addq_16_aw(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AW_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addq_16_al(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AL_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst; + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_addq_32_d(void) +{ + uint* r_dst = &DY; + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint dst = *r_dst; + uint res = src + dst; + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_addq_32_a(void) +{ + uint* r_dst = &AY; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst + (((REG_IR >> 9) - 1) & 7) + 1); +} + + +static void m68k_op_addq_32_ai(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_AI_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addq_32_pi(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PI_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addq_32_pd(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PD_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addq_32_di(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_DI_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addq_32_ix(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_IX_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addq_32_aw(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AW_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addq_32_al(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AL_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst; + + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_addx_8_rr(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_8(DY); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; +} + + +static void m68k_op_addx_16_rr(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_16(DY); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; +} + + +static void m68k_op_addx_32_rr(void) +{ + uint* r_dst = &DX; + uint src = DY; + uint dst = *r_dst; + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + *r_dst = res; +} + + +static void m68k_op_addx_8_mm_ax7(void) +{ + uint src = OPER_AY_PD_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_addx_8_mm_ay7(void) +{ + uint src = OPER_A7_PD_8(); + uint ea = EA_AX_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_addx_8_mm_axy7(void) +{ + uint src = OPER_A7_PD_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_addx_8_mm(void) +{ + uint src = OPER_AY_PD_8(); + uint ea = EA_AX_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_V = VFLAG_ADD_8(src, dst, res); + FLAG_X = FLAG_C = CFLAG_8(res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_addx_16_mm(void) +{ + uint src = OPER_AY_PD_16(); + uint ea = EA_AX_PD_16(); + uint dst = m68ki_read_16(ea); + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_V = VFLAG_ADD_16(src, dst, res); + FLAG_X = FLAG_C = CFLAG_16(res); + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_addx_32_mm(void) +{ + uint src = OPER_AY_PD_32(); + uint ea = EA_AX_PD_32(); + uint dst = m68ki_read_32(ea); + uint res = src + dst + XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_ADD_32(src, dst, res); + FLAG_X = FLAG_C = CFLAG_ADD_32(src, dst, res); + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_and_8_er_d(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (DY | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_ai(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_AI_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_pi(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_PI_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_pi7(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_A7_PI_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_pd(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_PD_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_pd7(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_A7_PD_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_di(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_DI_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_ix(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AY_IX_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_aw(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AW_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_al(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_AL_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_pcdi(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_PCDI_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_pcix(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_PCIX_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_er_i(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DX &= (OPER_I_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_d(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (DY | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_ai(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_AI_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_pi(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_PI_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_pd(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_PD_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_di(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_DI_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_ix(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AY_IX_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_aw(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AW_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_al(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_AL_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_pcdi(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_PCDI_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_pcix(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_PCIX_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_16_er_i(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DX &= (OPER_I_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_d(void) +{ + FLAG_Z = DX &= DY; + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_ai(void) +{ + FLAG_Z = DX &= OPER_AY_AI_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_pi(void) +{ + FLAG_Z = DX &= OPER_AY_PI_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_pd(void) +{ + FLAG_Z = DX &= OPER_AY_PD_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_di(void) +{ + FLAG_Z = DX &= OPER_AY_DI_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_ix(void) +{ + FLAG_Z = DX &= OPER_AY_IX_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_aw(void) +{ + FLAG_Z = DX &= OPER_AW_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_al(void) +{ + FLAG_Z = DX &= OPER_AL_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_pcdi(void) +{ + FLAG_Z = DX &= OPER_PCDI_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_pcix(void) +{ + FLAG_Z = DX &= OPER_PCIX_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_32_er_i(void) +{ + FLAG_Z = DX &= OPER_I_32(); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_and_8_re_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_8_re_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_8_re_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_8_re_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_8_re_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_8_re_di(void) +{ + uint ea = EA_AY_DI_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_8_re_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_8_re_aw(void) +{ + uint ea = EA_AW_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_8_re_al(void) +{ + uint ea = EA_AL_8(); + uint res = DX & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_and_16_re_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint res = DX & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_and_16_re_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint res = DX & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_and_16_re_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint res = DX & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_and_16_re_di(void) +{ + uint ea = EA_AY_DI_16(); + uint res = DX & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_and_16_re_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint res = DX & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_and_16_re_aw(void) +{ + uint ea = EA_AW_16(); + uint res = DX & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_and_16_re_al(void) +{ + uint ea = EA_AL_16(); + uint res = DX & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_and_32_re_ai(void) +{ + uint ea = EA_AY_AI_32(); + uint res = DX & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_and_32_re_pi(void) +{ + uint ea = EA_AY_PI_32(); + uint res = DX & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_and_32_re_pd(void) +{ + uint ea = EA_AY_PD_32(); + uint res = DX & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_and_32_re_di(void) +{ + uint ea = EA_AY_DI_32(); + uint res = DX & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_and_32_re_ix(void) +{ + uint ea = EA_AY_IX_32(); + uint res = DX & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_and_32_re_aw(void) +{ + uint ea = EA_AW_32(); + uint res = DX & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_and_32_re_al(void) +{ + uint ea = EA_AL_32(); + uint res = DX & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_andi_8_d(void) +{ + FLAG_Z = MASK_OUT_ABOVE_8(DY &= (OPER_I_8() | 0xffffff00)); + + FLAG_N = NFLAG_8(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_andi_8_ai(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_AI_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_8_pi(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PI_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_8_pi7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PI_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_8_pd(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PD_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_8_pd7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PD_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_8_di(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_DI_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_8_ix(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_IX_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_8_aw(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AW_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_8_al(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AL_8(); + uint res = src & m68ki_read_8(ea); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_andi_16_d(void) +{ + FLAG_Z = MASK_OUT_ABOVE_16(DY &= (OPER_I_16() | 0xffff0000)); + + FLAG_N = NFLAG_16(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_andi_16_ai(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_AI_16(); + uint res = src & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_andi_16_pi(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PI_16(); + uint res = src & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_andi_16_pd(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PD_16(); + uint res = src & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_andi_16_di(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_DI_16(); + uint res = src & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_andi_16_ix(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_IX_16(); + uint res = src & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_andi_16_aw(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AW_16(); + uint res = src & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_andi_16_al(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AL_16(); + uint res = src & m68ki_read_16(ea); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_andi_32_d(void) +{ + FLAG_Z = DY &= (OPER_I_32()); + + FLAG_N = NFLAG_32(FLAG_Z); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_andi_32_ai(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_AI_32(); + uint res = src & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_andi_32_pi(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PI_32(); + uint res = src & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_andi_32_pd(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PD_32(); + uint res = src & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_andi_32_di(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_DI_32(); + uint res = src & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_andi_32_ix(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_IX_32(); + uint res = src & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_andi_32_aw(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AW_32(); + uint res = src & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_andi_32_al(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AL_32(); + uint res = src & m68ki_read_32(ea); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_andi_16_toc(void) +{ + m68ki_set_ccr(m68ki_get_ccr() & OPER_I_16()); +} + + +static void m68k_op_andi_16_tos(void) +{ + if(FLAG_S) + { + uint src = OPER_I_16(); + m68ki_set_sr(m68ki_get_sr() & src); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_asr_8_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = src >> shift; + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + if(GET_MSB_8(src)) + res |= m68ki_shift_8_table[shift]; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_X = FLAG_C = src << (9-shift); +} + + +static void m68k_op_asr_16_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = src >> shift; + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + if(GET_MSB_16(src)) + res |= m68ki_shift_16_table[shift]; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_X = FLAG_C = src << (9-shift); +} + + +static void m68k_op_asr_32_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = *r_dst; + uint res = src >> shift; + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + if(GET_MSB_32(src)) + res |= m68ki_shift_32_table[shift]; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_X = FLAG_C = src << (9-shift); +} + + +static void m68k_op_asr_8_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = src >> shift; + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift < 8) + { + if(GET_MSB_8(src)) + res |= m68ki_shift_8_table[shift]; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_X = FLAG_C = src << (9-shift); + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + if(GET_MSB_8(src)) + { + *r_dst |= 0xff; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + FLAG_N = NFLAG_SET; + FLAG_Z = ZFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst &= 0xffffff00; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_8(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_asr_16_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = src >> shift; + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift < 16) + { + if(GET_MSB_16(src)) + res |= m68ki_shift_16_table[shift]; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_C = FLAG_X = (src >> (shift - 1))<<8; + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + if(GET_MSB_16(src)) + { + *r_dst |= 0xffff; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + FLAG_N = NFLAG_SET; + FLAG_Z = ZFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst &= 0xffff0000; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_16(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_asr_32_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = *r_dst; + uint res = src >> shift; + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift < 32) + { + if(GET_MSB_32(src)) + res |= m68ki_shift_32_table[shift]; + + *r_dst = res; + + FLAG_C = FLAG_X = (src >> (shift - 1))<<8; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + if(GET_MSB_32(src)) + { + *r_dst = 0xffffffff; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + FLAG_N = NFLAG_SET; + FLAG_Z = ZFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst = 0; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_32(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_asr_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + if(GET_MSB_16(src)) + res |= 0x8000; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = FLAG_X = src << 8; +} + + +static void m68k_op_asr_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + if(GET_MSB_16(src)) + res |= 0x8000; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = FLAG_X = src << 8; +} + + +static void m68k_op_asr_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + if(GET_MSB_16(src)) + res |= 0x8000; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = FLAG_X = src << 8; +} + + +static void m68k_op_asr_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + if(GET_MSB_16(src)) + res |= 0x8000; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = FLAG_X = src << 8; +} + + +static void m68k_op_asr_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + if(GET_MSB_16(src)) + res |= 0x8000; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = FLAG_X = src << 8; +} + + +static void m68k_op_asr_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + if(GET_MSB_16(src)) + res |= 0x8000; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = FLAG_X = src << 8; +} + + +static void m68k_op_asr_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + if(GET_MSB_16(src)) + res |= 0x8000; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = FLAG_X = src << 8; +} + + +static void m68k_op_asl_8_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = MASK_OUT_ABOVE_8(src << shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_X = FLAG_C = src << shift; + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + src &= m68ki_shift_8_table[shift + 1]; + FLAG_V = (!(src == 0 || (src == m68ki_shift_8_table[shift + 1] && shift < 8)))<<7; +} + + +static void m68k_op_asl_16_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = MASK_OUT_ABOVE_16(src << shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> (8-shift); + src &= m68ki_shift_16_table[shift + 1]; + FLAG_V = (!(src == 0 || src == m68ki_shift_16_table[shift + 1]))<<7; +} + + +static void m68k_op_asl_32_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = *r_dst; + uint res = MASK_OUT_ABOVE_32(src << shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> (24-shift); + src &= m68ki_shift_32_table[shift + 1]; + FLAG_V = (!(src == 0 || src == m68ki_shift_32_table[shift + 1]))<<7; +} + + +static void m68k_op_asl_8_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = MASK_OUT_ABOVE_8(src << shift); + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift < 8) + { + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + FLAG_X = FLAG_C = src << shift; + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + src &= m68ki_shift_8_table[shift + 1]; + FLAG_V = (!(src == 0 || src == m68ki_shift_8_table[shift + 1]))<<7; + return; + } + + *r_dst &= 0xffffff00; + FLAG_X = FLAG_C = ((shift == 8 ? src & 1 : 0))<<8; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = (!(src == 0))<<7; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_8(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_asl_16_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = MASK_OUT_ABOVE_16(src << shift); + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift < 16) + { + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + FLAG_X = FLAG_C = (src << shift) >> 8; + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + src &= m68ki_shift_16_table[shift + 1]; + FLAG_V = (!(src == 0 || src == m68ki_shift_16_table[shift + 1]))<<7; + return; + } + + *r_dst &= 0xffff0000; + FLAG_X = FLAG_C = ((shift == 16 ? src & 1 : 0))<<8; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = (!(src == 0))<<7; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_16(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_asl_32_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = *r_dst; + uint res = MASK_OUT_ABOVE_32(src << shift); + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift < 32) + { + *r_dst = res; + FLAG_X = FLAG_C = (src >> (32 - shift)) << 8; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + src &= m68ki_shift_32_table[shift + 1]; + FLAG_V = (!(src == 0 || src == m68ki_shift_32_table[shift + 1]))<<7; + return; + } + + *r_dst = 0; + FLAG_X = FLAG_C = ((shift == 32 ? src & 1 : 0))<<8; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = (!(src == 0))<<7; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_32(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_asl_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + src &= 0xc000; + FLAG_V = (!(src == 0 || src == 0xc000))<<7; +} + + +static void m68k_op_asl_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + src &= 0xc000; + FLAG_V = (!(src == 0 || src == 0xc000))<<7; +} + + +static void m68k_op_asl_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + src &= 0xc000; + FLAG_V = (!(src == 0 || src == 0xc000))<<7; +} + + +static void m68k_op_asl_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + src &= 0xc000; + FLAG_V = (!(src == 0 || src == 0xc000))<<7; +} + + +static void m68k_op_asl_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + src &= 0xc000; + FLAG_V = (!(src == 0 || src == 0xc000))<<7; +} + + +static void m68k_op_asl_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + src &= 0xc000; + FLAG_V = (!(src == 0 || src == 0xc000))<<7; +} + + +static void m68k_op_asl_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + src &= 0xc000; + FLAG_V = (!(src == 0 || src == 0xc000))<<7; +} + + +static void m68k_op_bhi_8(void) +{ + if(COND_HI()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bls_8(void) +{ + if(COND_LS()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bcc_8(void) +{ + if(COND_CC()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bcs_8(void) +{ + if(COND_CS()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bne_8(void) +{ + if(COND_NE()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_beq_8(void) +{ + if(COND_EQ()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bvc_8(void) +{ + if(COND_VC()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bvs_8(void) +{ + if(COND_VS()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bpl_8(void) +{ + if(COND_PL()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bmi_8(void) +{ + if(COND_MI()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bge_8(void) +{ + if(COND_GE()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_blt_8(void) +{ + if(COND_LT()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bgt_8(void) +{ + if(COND_GT()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_ble_8(void) +{ + if(COND_LE()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bhi_16(void) +{ + if(COND_HI()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bls_16(void) +{ + if(COND_LS()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bcc_16(void) +{ + if(COND_CC()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bcs_16(void) +{ + if(COND_CS()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bne_16(void) +{ + if(COND_NE()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_beq_16(void) +{ + if(COND_EQ()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bvc_16(void) +{ + if(COND_VC()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bvs_16(void) +{ + if(COND_VS()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bpl_16(void) +{ + if(COND_PL()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bmi_16(void) +{ + if(COND_MI()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bge_16(void) +{ + if(COND_GE()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_blt_16(void) +{ + if(COND_LT()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bgt_16(void) +{ + if(COND_GT()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_ble_16(void) +{ + if(COND_LE()) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_BCC_NOTAKE_W); +} + + +static void m68k_op_bhi_32(void) +{ + if(COND_HI()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bls_32(void) +{ + if(COND_LS()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bcc_32(void) +{ + if(COND_CC()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bcs_32(void) +{ + if(COND_CS()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bne_32(void) +{ + if(COND_NE()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_beq_32(void) +{ + if(COND_EQ()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bvc_32(void) +{ + if(COND_VC()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bvs_32(void) +{ + if(COND_VS()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bpl_32(void) +{ + if(COND_PL()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bmi_32(void) +{ + if(COND_MI()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bge_32(void) +{ + if(COND_GE()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_blt_32(void) +{ + if(COND_LT()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bgt_32(void) +{ + if(COND_GT()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_ble_32(void) +{ + if(COND_LE()) + { + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); + return; + } + USE_CYCLES(CYC_BCC_NOTAKE_B); +} + + +static void m68k_op_bchg_32_r_d(void) +{ + uint* r_dst = &DY; + uint mask = 1 << (DX & 0x1f); + + FLAG_Z = *r_dst & mask; + *r_dst ^= mask; +} + + +static void m68k_op_bchg_8_r_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_r_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_r_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_r_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_r_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_r_di(void) +{ + uint ea = EA_AY_DI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_r_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_r_aw(void) +{ + uint ea = EA_AW_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_r_al(void) +{ + uint ea = EA_AL_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_32_s_d(void) +{ + uint* r_dst = &DY; + uint mask = 1 << (OPER_I_8() & 0x1f); + + FLAG_Z = *r_dst & mask; + *r_dst ^= mask; +} + + +static void m68k_op_bchg_8_s_ai(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_AI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_s_pi(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_PI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_s_pi7(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_A7_PI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_s_pd(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_PD_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_s_pd7(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_A7_PD_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_s_di(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_DI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_s_ix(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_IX_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_s_aw(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AW_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bchg_8_s_al(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AL_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src ^ mask); +} + + +static void m68k_op_bclr_32_r_d(void) +{ + uint* r_dst = &DY; + uint mask = 1 << (DX & 0x1f); + + FLAG_Z = *r_dst & mask; + *r_dst &= ~mask; +} + + +static void m68k_op_bclr_8_r_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_r_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_r_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_r_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_r_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_r_di(void) +{ + uint ea = EA_AY_DI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_r_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_r_aw(void) +{ + uint ea = EA_AW_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_r_al(void) +{ + uint ea = EA_AL_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_32_s_d(void) +{ + uint* r_dst = &DY; + uint mask = 1 << (OPER_I_8() & 0x1f); + + FLAG_Z = *r_dst & mask; + *r_dst &= ~mask; +} + + +static void m68k_op_bclr_8_s_ai(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_AI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_s_pi(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_PI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_s_pi7(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_A7_PI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_s_pd(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_PD_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_s_pd7(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_A7_PD_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_s_di(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_DI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_s_ix(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_IX_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_s_aw(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AW_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bclr_8_s_al(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AL_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src & ~mask); +} + + +static void m68k_op_bra_8(void) +{ + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); +} + + +static void m68k_op_bra_16(void) +{ + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); +} + + +static void m68k_op_bra_32(void) +{ + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); +} + + +static void m68k_op_bset_32_r_d(void) +{ + uint* r_dst = &DY; + uint mask = 1 << (DX & 0x1f); + + FLAG_Z = *r_dst & mask; + *r_dst |= mask; +} + + +static void m68k_op_bset_8_r_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_r_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_r_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_r_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_r_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_r_di(void) +{ + uint ea = EA_AY_DI_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_r_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_r_aw(void) +{ + uint ea = EA_AW_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_r_al(void) +{ + uint ea = EA_AL_8(); + uint src = m68ki_read_8(ea); + uint mask = 1 << (DX & 7); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_32_s_d(void) +{ + uint* r_dst = &DY; + uint mask = 1 << (OPER_I_8() & 0x1f); + + FLAG_Z = *r_dst & mask; + *r_dst |= mask; +} + + +static void m68k_op_bset_8_s_ai(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_AI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_s_pi(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_PI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_s_pi7(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_A7_PI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_s_pd(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_PD_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_s_pd7(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_A7_PD_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_s_di(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_DI_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_s_ix(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AY_IX_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_s_aw(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AW_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bset_8_s_al(void) +{ + uint mask = 1 << (OPER_I_8() & 7); + uint ea = EA_AL_8(); + uint src = m68ki_read_8(ea); + + FLAG_Z = src & mask; + m68ki_write_8(ea, src | mask); +} + + +static void m68k_op_bsr_8(void) +{ + m68ki_push_32(REG_PC); + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); +} + + +static void m68k_op_bsr_16(void) +{ + uint offset = OPER_I_16(); + m68ki_push_32(REG_PC); + REG_PC -= 2; + m68ki_branch_16(offset); +} + + +static void m68k_op_bsr_32(void) +{ + m68ki_push_32(REG_PC); + m68ki_branch_8(MASK_OUT_ABOVE_8(REG_IR)); +} + + +static void m68k_op_btst_32_r_d(void) +{ + FLAG_Z = DY & (1 << (DX & 0x1f)); +} + + +static void m68k_op_btst_8_r_ai(void) +{ + FLAG_Z = OPER_AY_AI_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_pi(void) +{ + FLAG_Z = OPER_AY_PI_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_pi7(void) +{ + FLAG_Z = OPER_A7_PI_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_pd(void) +{ + FLAG_Z = OPER_AY_PD_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_pd7(void) +{ + FLAG_Z = OPER_A7_PD_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_di(void) +{ + FLAG_Z = OPER_AY_DI_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_ix(void) +{ + FLAG_Z = OPER_AY_IX_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_aw(void) +{ + FLAG_Z = OPER_AW_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_al(void) +{ + FLAG_Z = OPER_AL_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_pcdi(void) +{ + FLAG_Z = OPER_PCDI_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_pcix(void) +{ + FLAG_Z = OPER_PCIX_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_8_r_i(void) +{ + FLAG_Z = OPER_I_8() & (1 << (DX & 7)); +} + + +static void m68k_op_btst_32_s_d(void) +{ + FLAG_Z = DY & (1 << (OPER_I_8() & 0x1f)); +} + + +static void m68k_op_btst_8_s_ai(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_AY_AI_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_pi(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_AY_PI_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_pi7(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_A7_PI_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_pd(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_AY_PD_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_pd7(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_A7_PD_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_di(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_AY_DI_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_ix(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_AY_IX_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_aw(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_AW_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_al(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_AL_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_pcdi(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_PCDI_8() & (1 << bit); +} + + +static void m68k_op_btst_8_s_pcix(void) +{ + uint bit = OPER_I_8() & 7; + + FLAG_Z = OPER_PCIX_8() & (1 << bit); +} + + +static void m68k_op_chk_16_d(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(DY); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_ai(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_AY_AI_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_pi(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_AY_PI_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_pd(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_AY_PD_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_di(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_AY_DI_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_ix(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_AY_IX_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_aw(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_AW_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_al(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_AL_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_pcdi(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_PCDI_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_pcix(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_PCIX_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_chk_16_i(void) +{ + sint src = MAKE_INT_16(DX); + sint bound = MAKE_INT_16(OPER_I_16()); + + FLAG_Z = ZFLAG_16(src); /* Undocumented */ + FLAG_V = VFLAG_CLEAR; /* Undocumented */ + FLAG_C = CFLAG_CLEAR; /* Undocumented */ + + if(src >= 0 && src <= bound) + { + return; + } + FLAG_N = (src < 0)<<7; + m68ki_exception_trap(EXCEPTION_CHK); +} + + +static void m68k_op_clr_8_d(void) +{ + DY &= 0xffffff00; + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_8_al(void) +{ + m68ki_write_8(EA_AL_8(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_16_d(void) +{ + DY &= 0xffff0000; + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_16_ai(void) +{ + m68ki_write_16(EA_AY_AI_16(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_16_pi(void) +{ + m68ki_write_16(EA_AY_PI_16(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_16_pd(void) +{ + m68ki_write_16(EA_AY_PD_16(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_16_di(void) +{ + m68ki_write_16(EA_AY_DI_16(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_16_ix(void) +{ + m68ki_write_16(EA_AY_IX_16(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_16_aw(void) +{ + m68ki_write_16(EA_AW_16(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_16_al(void) +{ + m68ki_write_16(EA_AL_16(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_32_d(void) +{ + DY = 0; + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_32_ai(void) +{ + m68ki_write_32(EA_AY_AI_32(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_32_pi(void) +{ + m68ki_write_32(EA_AY_PI_32(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_32_pd(void) +{ + m68ki_write_32(EA_AY_PD_32(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_32_di(void) +{ + m68ki_write_32(EA_AY_DI_32(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_32_ix(void) +{ + m68ki_write_32(EA_AY_IX_32(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_32_aw(void) +{ + m68ki_write_32(EA_AW_32(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_clr_32_al(void) +{ + m68ki_write_32(EA_AL_32(), 0); + + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; +} + + +static void m68k_op_cmp_8_d(void) +{ + uint src = MASK_OUT_ABOVE_8(DY); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_ai(void) +{ + uint src = OPER_AY_AI_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_pi(void) +{ + uint src = OPER_AY_PI_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_pi7(void) +{ + uint src = OPER_A7_PI_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_pd(void) +{ + uint src = OPER_AY_PD_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_pd7(void) +{ + uint src = OPER_A7_PD_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_di(void) +{ + uint src = OPER_AY_DI_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_ix(void) +{ + uint src = OPER_AY_IX_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_aw(void) +{ + uint src = OPER_AW_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_al(void) +{ + uint src = OPER_AL_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_pcdi(void) +{ + uint src = OPER_PCDI_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_pcix(void) +{ + uint src = OPER_PCIX_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_8_i(void) +{ + uint src = OPER_I_8(); + uint dst = MASK_OUT_ABOVE_8(DX); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmp_16_d(void) +{ + uint src = MASK_OUT_ABOVE_16(DY); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_a(void) +{ + uint src = MASK_OUT_ABOVE_16(AY); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_ai(void) +{ + uint src = OPER_AY_AI_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_pi(void) +{ + uint src = OPER_AY_PI_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_pd(void) +{ + uint src = OPER_AY_PD_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_di(void) +{ + uint src = OPER_AY_DI_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_ix(void) +{ + uint src = OPER_AY_IX_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_aw(void) +{ + uint src = OPER_AW_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_al(void) +{ + uint src = OPER_AL_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_pcdi(void) +{ + uint src = OPER_PCDI_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_pcix(void) +{ + uint src = OPER_PCIX_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_16_i(void) +{ + uint src = OPER_I_16(); + uint dst = MASK_OUT_ABOVE_16(DX); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmp_32_d(void) +{ + uint src = DY; + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_a(void) +{ + uint src = AY; + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_ai(void) +{ + uint src = OPER_AY_AI_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_pi(void) +{ + uint src = OPER_AY_PI_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_pd(void) +{ + uint src = OPER_AY_PD_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_di(void) +{ + uint src = OPER_AY_DI_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_ix(void) +{ + uint src = OPER_AY_IX_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_aw(void) +{ + uint src = OPER_AW_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_al(void) +{ + uint src = OPER_AL_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_pcdi(void) +{ + uint src = OPER_PCDI_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_pcix(void) +{ + uint src = OPER_PCIX_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmp_32_i(void) +{ + uint src = OPER_I_32(); + uint dst = DX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_d(void) +{ + uint src = MAKE_INT_16(DY); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_a(void) +{ + uint src = MAKE_INT_16(AY); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_ai(void) +{ + uint src = MAKE_INT_16(OPER_AY_AI_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_pi(void) +{ + uint src = MAKE_INT_16(OPER_AY_PI_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_pd(void) +{ + uint src = MAKE_INT_16(OPER_AY_PD_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_di(void) +{ + uint src = MAKE_INT_16(OPER_AY_DI_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_ix(void) +{ + uint src = MAKE_INT_16(OPER_AY_IX_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_aw(void) +{ + uint src = MAKE_INT_16(OPER_AW_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_al(void) +{ + uint src = MAKE_INT_16(OPER_AL_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_pcdi(void) +{ + uint src = MAKE_INT_16(OPER_PCDI_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_pcix(void) +{ + uint src = MAKE_INT_16(OPER_PCIX_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_16_i(void) +{ + uint src = MAKE_INT_16(OPER_I_16()); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_d(void) +{ + uint src = DY; + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_a(void) +{ + uint src = AY; + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_ai(void) +{ + uint src = OPER_AY_AI_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_pi(void) +{ + uint src = OPER_AY_PI_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_pd(void) +{ + uint src = OPER_AY_PD_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_di(void) +{ + uint src = OPER_AY_DI_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_ix(void) +{ + uint src = OPER_AY_IX_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_aw(void) +{ + uint src = OPER_AW_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_al(void) +{ + uint src = OPER_AL_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_pcdi(void) +{ + uint src = OPER_PCDI_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_pcix(void) +{ + uint src = OPER_PCIX_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpa_32_i(void) +{ + uint src = OPER_I_32(); + uint dst = AX; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpi_8_d(void) +{ + uint src = OPER_I_8(); + uint dst = MASK_OUT_ABOVE_8(DY); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_ai(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_AY_AI_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_pi(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_AY_PI_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_pi7(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_A7_PI_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_pd(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_AY_PD_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_pd7(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_A7_PD_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_di(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_AY_DI_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_ix(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_AY_IX_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_aw(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_AW_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_8_al(void) +{ + uint src = OPER_I_8(); + uint dst = OPER_AL_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpi_16_d(void) +{ + uint src = OPER_I_16(); + uint dst = MASK_OUT_ABOVE_16(DY); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpi_16_ai(void) +{ + uint src = OPER_I_16(); + uint dst = OPER_AY_AI_16(); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpi_16_pi(void) +{ + uint src = OPER_I_16(); + uint dst = OPER_AY_PI_16(); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpi_16_pd(void) +{ + uint src = OPER_I_16(); + uint dst = OPER_AY_PD_16(); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpi_16_di(void) +{ + uint src = OPER_I_16(); + uint dst = OPER_AY_DI_16(); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpi_16_ix(void) +{ + uint src = OPER_I_16(); + uint dst = OPER_AY_IX_16(); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpi_16_aw(void) +{ + uint src = OPER_I_16(); + uint dst = OPER_AW_16(); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpi_16_al(void) +{ + uint src = OPER_I_16(); + uint dst = OPER_AL_16(); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpi_32_d(void) +{ + uint src = OPER_I_32(); + uint dst = DY; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpi_32_ai(void) +{ + uint src = OPER_I_32(); + uint dst = OPER_AY_AI_32(); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpi_32_pi(void) +{ + uint src = OPER_I_32(); + uint dst = OPER_AY_PI_32(); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpi_32_pd(void) +{ + uint src = OPER_I_32(); + uint dst = OPER_AY_PD_32(); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpi_32_di(void) +{ + uint src = OPER_I_32(); + uint dst = OPER_AY_DI_32(); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpi_32_ix(void) +{ + uint src = OPER_I_32(); + uint dst = OPER_AY_IX_32(); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpi_32_aw(void) +{ + uint src = OPER_I_32(); + uint dst = OPER_AW_32(); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpi_32_al(void) +{ + uint src = OPER_I_32(); + uint dst = OPER_AL_32(); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_cmpm_8_ax7(void) +{ + uint src = OPER_AY_PI_8(); + uint dst = OPER_A7_PI_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpm_8_ay7(void) +{ + uint src = OPER_A7_PI_8(); + uint dst = OPER_AX_PI_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpm_8_axy7(void) +{ + uint src = OPER_A7_PI_8(); + uint dst = OPER_A7_PI_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpm_8(void) +{ + uint src = OPER_AY_PI_8(); + uint dst = OPER_AX_PI_8(); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_C = CFLAG_8(res); +} + + +static void m68k_op_cmpm_16(void) +{ + uint src = OPER_AY_PI_16(); + uint dst = OPER_AX_PI_16(); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_C = CFLAG_16(res); +} + + +static void m68k_op_cmpm_32(void) +{ + uint src = OPER_AY_PI_32(); + uint dst = OPER_AX_PI_32(); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_C = CFLAG_SUB_32(src, dst, res); +} + + +static void m68k_op_dbt_16(void) +{ + REG_PC += 2; +} + + +static void m68k_op_dbf_16(void) +{ + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); +} + + +static void m68k_op_dbhi_16(void) +{ + if(COND_NOT_HI()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbls_16(void) +{ + if(COND_NOT_LS()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbcc_16(void) +{ + if(COND_NOT_CC()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbcs_16(void) +{ + if(COND_NOT_CS()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbne_16(void) +{ + if(COND_NOT_NE()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbeq_16(void) +{ + if(COND_NOT_EQ()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbvc_16(void) +{ + if(COND_NOT_VC()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbvs_16(void) +{ + if(COND_NOT_VS()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbpl_16(void) +{ + if(COND_NOT_PL()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbmi_16(void) +{ + if(COND_NOT_MI()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbge_16(void) +{ + if(COND_NOT_GE()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dblt_16(void) +{ + if(COND_NOT_LT()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dbgt_16(void) +{ + if(COND_NOT_GT()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_dble_16(void) +{ + if(COND_NOT_LE()) + { + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(*r_dst - 1); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + if(res != 0xffff) + { + uint offset = OPER_I_16(); + REG_PC -= 2; + m68ki_branch_16(offset); + USE_CYCLES(CYC_DBCC_F_NOEXP); + return; + } + REG_PC += 2; + USE_CYCLES(CYC_DBCC_F_EXP); + return; + } + REG_PC += 2; +} + + +static void m68k_op_divs_16_d(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(DY); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_ai(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_AI_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_pi(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_PI_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_pd(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_PD_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_di(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_DI_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_ix(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_IX_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_aw(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AW_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_al(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AL_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_pcdi(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_PCDI_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_pcix(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_PCIX_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divs_16_i(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_I_16()); + sint quotient; + sint remainder; + + if(src != 0) + { + UseDivsCycles(*r_dst,src); + + if((uint32)*r_dst == 0x80000000 && src == -1) + { + FLAG_Z = 0; + FLAG_N = NFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = 0; + return; + } + + quotient = MAKE_INT_32(*r_dst) / src; + remainder = MAKE_INT_32(*r_dst) % src; + + if(quotient == MAKE_INT_16(quotient)) + { + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_d(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_16(DY); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_ai(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_AI_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_pi(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PI_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 *10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_pd(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PD_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_di(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_DI_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_ix(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_IX_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_aw(void) +{ + uint* r_dst = &DX; + uint src = OPER_AW_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_al(void) +{ + uint* r_dst = &DX; + uint src = OPER_AL_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_pcdi(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCDI_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_pcix(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCIX_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_divu_16_i(void) +{ + uint* r_dst = &DX; + uint src = OPER_I_16(); + + if(src != 0) + { + uint quotient = *r_dst / src; + uint remainder = *r_dst % src; + + if(quotient < 0x10000) + { + UseDivuCycles(*r_dst,src); + FLAG_Z = quotient; + FLAG_N = NFLAG_16(quotient); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst = MASK_OUT_ABOVE_32(MASK_OUT_ABOVE_16(quotient) | (remainder << 16)); + return; + } + USE_CYCLES(7 * 10); + FLAG_V = VFLAG_SET; + FLAG_N = NFLAG_SET; /* undocumented behavior (fixes Blood Shot on Genesis) */ + FLAG_C = CFLAG_CLEAR; + return; + } + FLAG_C = CFLAG_CLEAR; + m68ki_exception_trap(EXCEPTION_ZERO_DIVIDE); +} + + +static void m68k_op_eor_8_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY ^= MASK_OUT_ABOVE_8(DX)); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_di(void) +{ + uint ea = EA_AY_DI_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_aw(void) +{ + uint ea = EA_AW_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_8_al(void) +{ + uint ea = EA_AL_8(); + uint res = MASK_OUT_ABOVE_8(DX ^ m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_16_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY ^= MASK_OUT_ABOVE_16(DX)); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_16_aw(void) +{ + uint ea = EA_AW_16(); + uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_16_al(void) +{ + uint ea = EA_AL_16(); + uint res = MASK_OUT_ABOVE_16(DX ^ m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_32_d(void) +{ + uint res = DY ^= DX; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_32_ai(void) +{ + uint ea = EA_AY_AI_32(); + uint res = DX ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_32_pi(void) +{ + uint ea = EA_AY_PI_32(); + uint res = DX ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_32_pd(void) +{ + uint ea = EA_AY_PD_32(); + uint res = DX ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_32_di(void) +{ + uint ea = EA_AY_DI_32(); + uint res = DX ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_32_ix(void) +{ + uint ea = EA_AY_IX_32(); + uint res = DX ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_32_aw(void) +{ + uint ea = EA_AW_32(); + uint res = DX ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eor_32_al(void) +{ + uint ea = EA_AL_32(); + uint res = DX ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY ^= OPER_I_8()); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_ai(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_AI_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_pi(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PI_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_pi7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PI_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_pd(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PD_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_pd7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PD_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_di(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_DI_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_ix(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_IX_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_aw(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AW_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_8_al(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AL_8(); + uint res = src ^ m68ki_read_8(ea); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY ^= OPER_I_16()); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_ai(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_AI_16(); + uint res = src ^ m68ki_read_16(ea); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_pi(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PI_16(); + uint res = src ^ m68ki_read_16(ea); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_pd(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PD_16(); + uint res = src ^ m68ki_read_16(ea); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_di(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_DI_16(); + uint res = src ^ m68ki_read_16(ea); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_ix(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_IX_16(); + uint res = src ^ m68ki_read_16(ea); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_aw(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AW_16(); + uint res = src ^ m68ki_read_16(ea); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_al(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AL_16(); + uint res = src ^ m68ki_read_16(ea); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_32_d(void) +{ + uint res = DY ^= OPER_I_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_32_ai(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_AI_32(); + uint res = src ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_32_pi(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PI_32(); + uint res = src ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_32_pd(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PD_32(); + uint res = src ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_32_di(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_DI_32(); + uint res = src ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_32_ix(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_IX_32(); + uint res = src ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_32_aw(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AW_32(); + uint res = src ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_32_al(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AL_32(); + uint res = src ^ m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_eori_16_toc(void) +{ + m68ki_set_ccr(m68ki_get_ccr() ^ OPER_I_16()); +} + + +static void m68k_op_eori_16_tos(void) +{ + if(FLAG_S) + { + uint src = OPER_I_16(); + m68ki_set_sr(m68ki_get_sr() ^ src); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_exg_32_dd(void) +{ + uint* reg_a = &DX; + uint* reg_b = &DY; + uint tmp = *reg_a; + *reg_a = *reg_b; + *reg_b = tmp; +} + + +static void m68k_op_exg_32_aa(void) +{ + uint* reg_a = &AX; + uint* reg_b = &AY; + uint tmp = *reg_a; + *reg_a = *reg_b; + *reg_b = tmp; +} + + +static void m68k_op_exg_32_da(void) +{ + uint* reg_a = &DX; + uint* reg_b = &AY; + uint tmp = *reg_a; + *reg_a = *reg_b; + *reg_b = tmp; +} + + +static void m68k_op_ext_16(void) +{ + uint* r_dst = &DY; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | MASK_OUT_ABOVE_8(*r_dst) | (GET_MSB_8(*r_dst) ? 0xff00 : 0); + + FLAG_N = NFLAG_16(*r_dst); + FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_ext_32(void) +{ + uint* r_dst = &DY; + + *r_dst = MASK_OUT_ABOVE_16(*r_dst) | (GET_MSB_16(*r_dst) ? 0xffff0000 : 0); + + FLAG_N = NFLAG_32(*r_dst); + FLAG_Z = *r_dst; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_illegal(void) +{ + m68ki_exception_illegal(); +} + + +static void m68k_op_jmp_32_ai(void) +{ + m68ki_jump(EA_AY_AI_32()); +} + + +static void m68k_op_jmp_32_di(void) +{ + m68ki_jump(EA_AY_DI_32()); +} + + +static void m68k_op_jmp_32_ix(void) +{ + m68ki_jump(EA_AY_IX_32()); +} + + +static void m68k_op_jmp_32_aw(void) +{ + m68ki_jump(EA_AW_32()); +} + + +static void m68k_op_jmp_32_al(void) +{ + m68ki_jump(EA_AL_32()); +} + + +static void m68k_op_jmp_32_pcdi(void) +{ + m68ki_jump(EA_PCDI_32()); +} + + +static void m68k_op_jmp_32_pcix(void) +{ + m68ki_jump(EA_PCIX_32()); +} + + +static void m68k_op_jsr_32_ai(void) +{ + uint ea = EA_AY_AI_32(); + m68ki_push_32(REG_PC); + m68ki_jump(ea); +} + + +static void m68k_op_jsr_32_di(void) +{ + uint ea = EA_AY_DI_32(); + m68ki_push_32(REG_PC); + m68ki_jump(ea); +} + + +static void m68k_op_jsr_32_ix(void) +{ + uint ea = EA_AY_IX_32(); + m68ki_push_32(REG_PC); + m68ki_jump(ea); +} + + +static void m68k_op_jsr_32_aw(void) +{ + uint ea = EA_AW_32(); + m68ki_push_32(REG_PC); + m68ki_jump(ea); +} + + +static void m68k_op_jsr_32_al(void) +{ + uint ea = EA_AL_32(); + m68ki_push_32(REG_PC); + m68ki_jump(ea); +} + + +static void m68k_op_jsr_32_pcdi(void) +{ + uint ea = EA_PCDI_32(); + m68ki_push_32(REG_PC); + m68ki_jump(ea); +} + + +static void m68k_op_jsr_32_pcix(void) +{ + uint ea = EA_PCIX_32(); + m68ki_push_32(REG_PC); + m68ki_jump(ea); +} + + +static void m68k_op_lea_32_ai(void) +{ + AX = EA_AY_AI_32(); +} + + +static void m68k_op_lea_32_di(void) +{ + AX = EA_AY_DI_32(); +} + + +static void m68k_op_lea_32_ix(void) +{ + AX = EA_AY_IX_32(); +} + + +static void m68k_op_lea_32_aw(void) +{ + AX = EA_AW_32(); +} + + +static void m68k_op_lea_32_al(void) +{ + AX = EA_AL_32(); +} + + +static void m68k_op_lea_32_pcdi(void) +{ + AX = EA_PCDI_32(); +} + + +static void m68k_op_lea_32_pcix(void) +{ + AX = EA_PCIX_32(); +} + + +static void m68k_op_link_16_a7(void) +{ + REG_A[7] -= 4; + m68ki_write_32(REG_A[7], REG_A[7]); + REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16())); +} + + +static void m68k_op_link_16(void) +{ + uint* r_dst = &AY; + + m68ki_push_32(*r_dst); + *r_dst = REG_A[7]; + REG_A[7] = MASK_OUT_ABOVE_32(REG_A[7] + MAKE_INT_16(OPER_I_16())); +} + + +static void m68k_op_lsr_8_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = src >> shift; + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_X = FLAG_C = src << (9-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = src >> shift; + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_X = FLAG_C = src << (9-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_32_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = *r_dst; + uint res = src >> shift; + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = res; + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_X = FLAG_C = src << (9-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_8_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = src >> shift; + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift <= 8) + { + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + FLAG_X = FLAG_C = src << (9-shift); + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst &= 0xffffff00; + FLAG_X = XFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_8(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = src >> shift; + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift <= 16) + { + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + FLAG_C = FLAG_X = (src >> (shift - 1))<<8; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst &= 0xffff0000; + FLAG_X = XFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_16(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_32_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = *r_dst; + uint res = src >> shift; + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift < 32) + { + *r_dst = res; + FLAG_C = FLAG_X = (src >> (shift - 1))<<8; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst = 0; + FLAG_X = FLAG_C = (shift == 32 ? GET_MSB_32(src)>>23 : 0); + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_32(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_C = FLAG_X = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_C = FLAG_X = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_C = FLAG_X = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_C = FLAG_X = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_C = FLAG_X = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_C = FLAG_X = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsr_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = src >> 1; + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_CLEAR; + FLAG_Z = res; + FLAG_C = FLAG_X = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_8_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = MASK_OUT_ABOVE_8(src << shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src << shift; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = MASK_OUT_ABOVE_16(src << shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> (8-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_32_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = *r_dst; + uint res = MASK_OUT_ABOVE_32(src << shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> (24-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_8_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = MASK_OUT_ABOVE_8(src << shift); + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift <= 8) + { + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + FLAG_X = FLAG_C = src << shift; + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst &= 0xffffff00; + FLAG_X = XFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_8(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = MASK_OUT_ABOVE_16(src << shift); + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift <= 16) + { + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + FLAG_X = FLAG_C = (src << shift) >> 8; + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst &= 0xffff0000; + FLAG_X = XFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_16(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_32_r(void) +{ + uint* r_dst = &DY; + uint shift = DX & 0x3f; + uint src = *r_dst; + uint res = MASK_OUT_ABOVE_32(src << shift); + + if(shift != 0) + { + USE_CYCLES(shift * CYC_SHIFT); + + if(shift < 32) + { + *r_dst = res; + FLAG_X = FLAG_C = (src >> (32 - shift)) << 8; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + *r_dst = 0; + FLAG_X = FLAG_C = ((shift == 32 ? src & 1 : 0))<<8; + FLAG_N = NFLAG_CLEAR; + FLAG_Z = ZFLAG_SET; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_32(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_lsl_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(src << 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_X = FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_di(void) +{ + uint res = OPER_AY_DI_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_aw(void) +{ + uint res = OPER_AW_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_al(void) +{ + uint res = OPER_AL_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_d_i(void) +{ + uint res = OPER_I_8(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_8_ai_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ai_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_AX_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi7_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pi_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_AX_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd7_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_pd_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_AX_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_di_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_AX_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_ix_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_AX_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_aw_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_ai(void) +{ + uint res = OPER_AY_AI_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_pi(void) +{ + uint res = OPER_AY_PI_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_pi7(void) +{ + uint res = OPER_A7_PI_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_pd(void) +{ + uint res = OPER_AY_PD_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_pd7(void) +{ + uint res = OPER_A7_PD_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_di(void) +{ + uint res = OPER_AY_DI_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_ix(void) +{ + uint res = OPER_AY_IX_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_aw(void) +{ + uint res = OPER_AW_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_al(void) +{ + uint res = OPER_AL_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_pcdi(void) +{ + uint res = OPER_PCDI_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_pcix(void) +{ + uint res = OPER_PCIX_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_8_al_i(void) +{ + uint res = OPER_I_8(); + uint ea = EA_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_move_16_d_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_a(void) +{ + uint res = MASK_OUT_ABOVE_16(AY); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_ai(void) +{ + uint res = OPER_AY_AI_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_pi(void) +{ + uint res = OPER_AY_PI_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_pd(void) +{ + uint res = OPER_AY_PD_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_di(void) +{ + uint res = OPER_AY_DI_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_ix(void) +{ + uint res = OPER_AY_IX_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_aw(void) +{ + uint res = OPER_AW_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_al(void) +{ + uint res = OPER_AL_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_pcdi(void) +{ + uint res = OPER_PCDI_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_pcix(void) +{ + uint res = OPER_PCIX_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_d_i(void) +{ + uint res = OPER_I_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_16_ai_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_a(void) +{ + uint res = MASK_OUT_ABOVE_16(AY); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_ai(void) +{ + uint res = OPER_AY_AI_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_pi(void) +{ + uint res = OPER_AY_PI_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_pd(void) +{ + uint res = OPER_AY_PD_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_di(void) +{ + uint res = OPER_AY_DI_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_ix(void) +{ + uint res = OPER_AY_IX_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_aw(void) +{ + uint res = OPER_AW_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_al(void) +{ + uint res = OPER_AL_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_pcdi(void) +{ + uint res = OPER_PCDI_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_pcix(void) +{ + uint res = OPER_PCIX_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ai_i(void) +{ + uint res = OPER_I_16(); + uint ea = EA_AX_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_a(void) +{ + uint res = MASK_OUT_ABOVE_16(AY); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_ai(void) +{ + uint res = OPER_AY_AI_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_pi(void) +{ + uint res = OPER_AY_PI_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_pd(void) +{ + uint res = OPER_AY_PD_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_di(void) +{ + uint res = OPER_AY_DI_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_ix(void) +{ + uint res = OPER_AY_IX_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_aw(void) +{ + uint res = OPER_AW_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_al(void) +{ + uint res = OPER_AL_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_pcdi(void) +{ + uint res = OPER_PCDI_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_pcix(void) +{ + uint res = OPER_PCIX_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pi_i(void) +{ + uint res = OPER_I_16(); + uint ea = EA_AX_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_a(void) +{ + uint res = MASK_OUT_ABOVE_16(AY); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_ai(void) +{ + uint res = OPER_AY_AI_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_pi(void) +{ + uint res = OPER_AY_PI_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_pd(void) +{ + uint res = OPER_AY_PD_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_di(void) +{ + uint res = OPER_AY_DI_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_ix(void) +{ + uint res = OPER_AY_IX_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_aw(void) +{ + uint res = OPER_AW_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_al(void) +{ + uint res = OPER_AL_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_pcdi(void) +{ + uint res = OPER_PCDI_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_pcix(void) +{ + uint res = OPER_PCIX_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_pd_i(void) +{ + uint res = OPER_I_16(); + uint ea = EA_AX_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_a(void) +{ + uint res = MASK_OUT_ABOVE_16(AY); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_ai(void) +{ + uint res = OPER_AY_AI_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_pi(void) +{ + uint res = OPER_AY_PI_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_pd(void) +{ + uint res = OPER_AY_PD_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_di(void) +{ + uint res = OPER_AY_DI_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_ix(void) +{ + uint res = OPER_AY_IX_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_aw(void) +{ + uint res = OPER_AW_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_al(void) +{ + uint res = OPER_AL_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_pcdi(void) +{ + uint res = OPER_PCDI_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_pcix(void) +{ + uint res = OPER_PCIX_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_di_i(void) +{ + uint res = OPER_I_16(); + uint ea = EA_AX_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_a(void) +{ + uint res = MASK_OUT_ABOVE_16(AY); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_ai(void) +{ + uint res = OPER_AY_AI_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_pi(void) +{ + uint res = OPER_AY_PI_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_pd(void) +{ + uint res = OPER_AY_PD_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_di(void) +{ + uint res = OPER_AY_DI_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_ix(void) +{ + uint res = OPER_AY_IX_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_aw(void) +{ + uint res = OPER_AW_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_al(void) +{ + uint res = OPER_AL_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_pcdi(void) +{ + uint res = OPER_PCDI_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_pcix(void) +{ + uint res = OPER_PCIX_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_ix_i(void) +{ + uint res = OPER_I_16(); + uint ea = EA_AX_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_a(void) +{ + uint res = MASK_OUT_ABOVE_16(AY); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_ai(void) +{ + uint res = OPER_AY_AI_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_pi(void) +{ + uint res = OPER_AY_PI_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_pd(void) +{ + uint res = OPER_AY_PD_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_di(void) +{ + uint res = OPER_AY_DI_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_ix(void) +{ + uint res = OPER_AY_IX_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_aw(void) +{ + uint res = OPER_AW_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_al(void) +{ + uint res = OPER_AL_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_pcdi(void) +{ + uint res = OPER_PCDI_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_pcix(void) +{ + uint res = OPER_PCIX_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_aw_i(void) +{ + uint res = OPER_I_16(); + uint ea = EA_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_a(void) +{ + uint res = MASK_OUT_ABOVE_16(AY); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_ai(void) +{ + uint res = OPER_AY_AI_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_pi(void) +{ + uint res = OPER_AY_PI_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_pd(void) +{ + uint res = OPER_AY_PD_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_di(void) +{ + uint res = OPER_AY_DI_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_ix(void) +{ + uint res = OPER_AY_IX_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_aw(void) +{ + uint res = OPER_AW_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_al(void) +{ + uint res = OPER_AL_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_pcdi(void) +{ + uint res = OPER_PCDI_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_pcix(void) +{ + uint res = OPER_PCIX_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_16_al_i(void) +{ + uint res = OPER_I_16(); + uint ea = EA_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_move_32_d_d(void) +{ + uint res = DY; + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_a(void) +{ + uint res = AY; + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_ai(void) +{ + uint res = OPER_AY_AI_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_pi(void) +{ + uint res = OPER_AY_PI_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_pd(void) +{ + uint res = OPER_AY_PD_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_di(void) +{ + uint res = OPER_AY_DI_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_ix(void) +{ + uint res = OPER_AY_IX_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_aw(void) +{ + uint res = OPER_AW_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_al(void) +{ + uint res = OPER_AL_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_pcdi(void) +{ + uint res = OPER_PCDI_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_pcix(void) +{ + uint res = OPER_PCIX_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_d_i(void) +{ + uint res = OPER_I_32(); + uint* r_dst = &DX; + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_move_32_ai_d(void) +{ + uint res = DY; + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_a(void) +{ + uint res = AY; + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_ai(void) +{ + uint res = OPER_AY_AI_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_pi(void) +{ + uint res = OPER_AY_PI_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_pd(void) +{ + uint res = OPER_AY_PD_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_di(void) +{ + uint res = OPER_AY_DI_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_ix(void) +{ + uint res = OPER_AY_IX_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_aw(void) +{ + uint res = OPER_AW_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_al(void) +{ + uint res = OPER_AL_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_pcdi(void) +{ + uint res = OPER_PCDI_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_pcix(void) +{ + uint res = OPER_PCIX_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ai_i(void) +{ + uint res = OPER_I_32(); + uint ea = EA_AX_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_d(void) +{ + uint res = DY; + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_a(void) +{ + uint res = AY; + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_ai(void) +{ + uint res = OPER_AY_AI_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_pi(void) +{ + uint res = OPER_AY_PI_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_pd(void) +{ + uint res = OPER_AY_PD_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_di(void) +{ + uint res = OPER_AY_DI_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_ix(void) +{ + uint res = OPER_AY_IX_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_aw(void) +{ + uint res = OPER_AW_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_al(void) +{ + uint res = OPER_AL_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_pcdi(void) +{ + uint res = OPER_PCDI_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_pcix(void) +{ + uint res = OPER_PCIX_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pi_i(void) +{ + uint res = OPER_I_32(); + uint ea = EA_AX_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_pd_d(void) +{ + uint res = DY; + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_a(void) +{ + uint res = AY; + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_ai(void) +{ + uint res = OPER_AY_AI_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_pi(void) +{ + uint res = OPER_AY_PI_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_pd(void) +{ + uint res = OPER_AY_PD_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_di(void) +{ + uint res = OPER_AY_DI_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_ix(void) +{ + uint res = OPER_AY_IX_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_aw(void) +{ + uint res = OPER_AW_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_al(void) +{ + uint res = OPER_AL_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_pcdi(void) +{ + uint res = OPER_PCDI_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_pcix(void) +{ + uint res = OPER_PCIX_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_pd_i(void) +{ + uint res = OPER_I_32(); + uint ea = EA_AX_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_16(ea+2, res & 0xFFFF ); + m68ki_write_16(ea, (res >> 16) & 0xFFFF ); +} + + +static void m68k_op_move_32_di_d(void) +{ + uint res = DY; + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_a(void) +{ + uint res = AY; + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_ai(void) +{ + uint res = OPER_AY_AI_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_pi(void) +{ + uint res = OPER_AY_PI_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_pd(void) +{ + uint res = OPER_AY_PD_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_di(void) +{ + uint res = OPER_AY_DI_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_ix(void) +{ + uint res = OPER_AY_IX_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_aw(void) +{ + uint res = OPER_AW_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_al(void) +{ + uint res = OPER_AL_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_pcdi(void) +{ + uint res = OPER_PCDI_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_pcix(void) +{ + uint res = OPER_PCIX_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_di_i(void) +{ + uint res = OPER_I_32(); + uint ea = EA_AX_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_d(void) +{ + uint res = DY; + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_a(void) +{ + uint res = AY; + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_ai(void) +{ + uint res = OPER_AY_AI_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_pi(void) +{ + uint res = OPER_AY_PI_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_pd(void) +{ + uint res = OPER_AY_PD_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_di(void) +{ + uint res = OPER_AY_DI_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_ix(void) +{ + uint res = OPER_AY_IX_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_aw(void) +{ + uint res = OPER_AW_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_al(void) +{ + uint res = OPER_AL_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_pcdi(void) +{ + uint res = OPER_PCDI_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_pcix(void) +{ + uint res = OPER_PCIX_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_ix_i(void) +{ + uint res = OPER_I_32(); + uint ea = EA_AX_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_d(void) +{ + uint res = DY; + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_a(void) +{ + uint res = AY; + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_ai(void) +{ + uint res = OPER_AY_AI_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_pi(void) +{ + uint res = OPER_AY_PI_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_pd(void) +{ + uint res = OPER_AY_PD_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_di(void) +{ + uint res = OPER_AY_DI_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_ix(void) +{ + uint res = OPER_AY_IX_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_aw(void) +{ + uint res = OPER_AW_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_al(void) +{ + uint res = OPER_AL_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_pcdi(void) +{ + uint res = OPER_PCDI_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_pcix(void) +{ + uint res = OPER_PCIX_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_aw_i(void) +{ + uint res = OPER_I_32(); + uint ea = EA_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_d(void) +{ + uint res = DY; + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_a(void) +{ + uint res = AY; + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_ai(void) +{ + uint res = OPER_AY_AI_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_pi(void) +{ + uint res = OPER_AY_PI_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_pd(void) +{ + uint res = OPER_AY_PD_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_di(void) +{ + uint res = OPER_AY_DI_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_ix(void) +{ + uint res = OPER_AY_IX_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_aw(void) +{ + uint res = OPER_AW_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_al(void) +{ + uint res = OPER_AL_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_pcdi(void) +{ + uint res = OPER_PCDI_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_pcix(void) +{ + uint res = OPER_PCIX_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_move_32_al_i(void) +{ + uint res = OPER_I_32(); + uint ea = EA_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_movea_16_d(void) +{ + AX = MAKE_INT_16(DY); +} + + +static void m68k_op_movea_16_a(void) +{ + AX = MAKE_INT_16(AY); +} + + +static void m68k_op_movea_16_ai(void) +{ + AX = MAKE_INT_16(OPER_AY_AI_16()); +} + + +static void m68k_op_movea_16_pi(void) +{ + AX = MAKE_INT_16(OPER_AY_PI_16()); +} + + +static void m68k_op_movea_16_pd(void) +{ + AX = MAKE_INT_16(OPER_AY_PD_16()); +} + + +static void m68k_op_movea_16_di(void) +{ + AX = MAKE_INT_16(OPER_AY_DI_16()); +} + + +static void m68k_op_movea_16_ix(void) +{ + AX = MAKE_INT_16(OPER_AY_IX_16()); +} + + +static void m68k_op_movea_16_aw(void) +{ + AX = MAKE_INT_16(OPER_AW_16()); +} + + +static void m68k_op_movea_16_al(void) +{ + AX = MAKE_INT_16(OPER_AL_16()); +} + + +static void m68k_op_movea_16_pcdi(void) +{ + AX = MAKE_INT_16(OPER_PCDI_16()); +} + + +static void m68k_op_movea_16_pcix(void) +{ + AX = MAKE_INT_16(OPER_PCIX_16()); +} + + +static void m68k_op_movea_16_i(void) +{ + AX = MAKE_INT_16(OPER_I_16()); +} + + +static void m68k_op_movea_32_d(void) +{ + AX = DY; +} + + +static void m68k_op_movea_32_a(void) +{ + AX = AY; +} + + +static void m68k_op_movea_32_ai(void) +{ + AX = OPER_AY_AI_32(); +} + + +static void m68k_op_movea_32_pi(void) +{ + AX = OPER_AY_PI_32(); +} + + +static void m68k_op_movea_32_pd(void) +{ + AX = OPER_AY_PD_32(); +} + + +static void m68k_op_movea_32_di(void) +{ + AX = OPER_AY_DI_32(); +} + + +static void m68k_op_movea_32_ix(void) +{ + AX = OPER_AY_IX_32(); +} + + +static void m68k_op_movea_32_aw(void) +{ + AX = OPER_AW_32(); +} + + +static void m68k_op_movea_32_al(void) +{ + AX = OPER_AL_32(); +} + + +static void m68k_op_movea_32_pcdi(void) +{ + AX = OPER_PCDI_32(); +} + + +static void m68k_op_movea_32_pcix(void) +{ + AX = OPER_PCIX_32(); +} + + +static void m68k_op_movea_32_i(void) +{ + AX = OPER_I_32(); +} + +static void m68k_op_move_16_toc_d(void) +{ + m68ki_set_ccr(DY); +} + + +static void m68k_op_move_16_toc_ai(void) +{ + m68ki_set_ccr(OPER_AY_AI_16()); +} + + +static void m68k_op_move_16_toc_pi(void) +{ + m68ki_set_ccr(OPER_AY_PI_16()); +} + + +static void m68k_op_move_16_toc_pd(void) +{ + m68ki_set_ccr(OPER_AY_PD_16()); +} + + +static void m68k_op_move_16_toc_di(void) +{ + m68ki_set_ccr(OPER_AY_DI_16()); +} + + +static void m68k_op_move_16_toc_ix(void) +{ + m68ki_set_ccr(OPER_AY_IX_16()); +} + + +static void m68k_op_move_16_toc_aw(void) +{ + m68ki_set_ccr(OPER_AW_16()); +} + + +static void m68k_op_move_16_toc_al(void) +{ + m68ki_set_ccr(OPER_AL_16()); +} + + +static void m68k_op_move_16_toc_pcdi(void) +{ + m68ki_set_ccr(OPER_PCDI_16()); +} + + +static void m68k_op_move_16_toc_pcix(void) +{ + m68ki_set_ccr(OPER_PCIX_16()); +} + + +static void m68k_op_move_16_toc_i(void) +{ + m68ki_set_ccr(OPER_I_16()); +} + + +static void m68k_op_move_16_frs_d(void) +{ + DY = MASK_OUT_BELOW_16(DY) | m68ki_get_sr(); +} + + +static void m68k_op_move_16_frs_ai(void) +{ + uint ea = EA_AY_AI_16(); + m68ki_write_16(ea, m68ki_get_sr()); +} + + +static void m68k_op_move_16_frs_pi(void) +{ + uint ea = EA_AY_PI_16(); + m68ki_write_16(ea, m68ki_get_sr()); +} + + +static void m68k_op_move_16_frs_pd(void) +{ + uint ea = EA_AY_PD_16(); + m68ki_write_16(ea, m68ki_get_sr()); +} + + +static void m68k_op_move_16_frs_di(void) +{ + uint ea = EA_AY_DI_16(); + m68ki_write_16(ea, m68ki_get_sr()); +} + + +static void m68k_op_move_16_frs_ix(void) +{ + uint ea = EA_AY_IX_16(); + m68ki_write_16(ea, m68ki_get_sr()); +} + + +static void m68k_op_move_16_frs_aw(void) +{ + uint ea = EA_AW_16(); + m68ki_write_16(ea, m68ki_get_sr()); +} + + +static void m68k_op_move_16_frs_al(void) +{ + uint ea = EA_AL_16(); + m68ki_write_16(ea, m68ki_get_sr()); +} + + +static void m68k_op_move_16_tos_d(void) +{ + if(FLAG_S) + { + m68ki_set_sr(DY); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_ai(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_AY_AI_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_pi(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_AY_PI_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_pd(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_AY_PD_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_di(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_AY_DI_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_ix(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_AY_IX_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_aw(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_AW_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_al(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_AL_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_pcdi(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_PCDI_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_pcix(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_PCIX_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_16_tos_i(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_I_16(); + m68ki_set_sr(new_sr); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_32_fru(void) +{ + if(FLAG_S) + { + AY = REG_USP; + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_move_32_tou(void) +{ + if(FLAG_S) + { + REG_USP = AY; + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_movem_16_re_pd(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = AY; + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + ea -= 2; + m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[15-i])); + count++; + } + AY = ea; + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_re_ai(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_AI_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_re_di(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_DI_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_re_ix(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_IX_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_re_aw(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AW_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_re_al(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AL_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_16(ea, MASK_OUT_ABOVE_16(REG_DA[i])); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_32_re_pd(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = AY; + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + ea -= 4; + m68ki_write_16(ea+2, REG_DA[15-i] & 0xFFFF ); + m68ki_write_16(ea, (REG_DA[15-i] >> 16) & 0xFFFF ); + count++; + } + AY = ea; + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_re_ai(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_AI_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_32(ea, REG_DA[i]); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_re_di(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_DI_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_32(ea, REG_DA[i]); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_re_ix(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_IX_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_32(ea, REG_DA[i]); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_re_aw(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AW_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_32(ea, REG_DA[i]); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_re_al(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AL_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + m68ki_write_32(ea, REG_DA[i]); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_16_er_pi(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = AY; + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); + ea += 2; + count++; + } + AY = ea; + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_er_pcdi(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_PCDI_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_pcrel_16(ea))); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_er_pcix(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_PCIX_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_pcrel_16(ea))); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_er_ai(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_AI_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_er_di(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_DI_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_er_ix(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_IX_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_er_aw(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AW_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_16_er_al(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AL_16(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = MAKE_INT_16(MASK_OUT_ABOVE_16(m68ki_read_16(ea))); + ea += 2; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_W); +} + + +static void m68k_op_movem_32_er_pi(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = AY; + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = m68ki_read_32(ea); + ea += 4; + count++; + } + AY = ea; + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_er_pcdi(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_PCDI_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = m68ki_read_pcrel_32(ea); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_er_pcix(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_PCIX_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = m68ki_read_pcrel_32(ea); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_er_ai(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_AI_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = m68ki_read_32(ea); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_er_di(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_DI_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = m68ki_read_32(ea); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_er_ix(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AY_IX_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = m68ki_read_32(ea); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_er_aw(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AW_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = m68ki_read_32(ea); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movem_32_er_al(void) +{ + uint i = 0; + uint register_list = OPER_I_16(); + uint ea = EA_AL_32(); + uint count = 0; + + for(; i < 16; i++) + if(register_list & (1 << i)) + { + REG_DA[i] = m68ki_read_32(ea); + ea += 4; + count++; + } + + USE_CYCLES(count * CYC_MOVEM_L); +} + + +static void m68k_op_movep_16_re(void) +{ + uint ea = EA_AY_DI_16(); + uint src = DX; + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(src >> 8)); + m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src)); +} + + +static void m68k_op_movep_32_re(void) +{ + uint ea = EA_AY_DI_32(); + uint src = DX; + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(src >> 24)); + m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src >> 16)); + m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src >> 8)); + m68ki_write_8(ea += 2, MASK_OUT_ABOVE_8(src)); +} + + +static void m68k_op_movep_16_er(void) +{ + uint ea = EA_AY_DI_16(); + uint* r_dst = &DX; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | ((m68ki_read_8(ea) << 8) + m68ki_read_8(ea + 2)); +} + + +static void m68k_op_movep_32_er(void) +{ + uint ea = EA_AY_DI_32(); + + DX = (m68ki_read_8(ea) << 24) + (m68ki_read_8(ea + 2) << 16) + + (m68ki_read_8(ea + 4) << 8) + m68ki_read_8(ea + 6); +} + + +static void m68k_op_moveq_32(void) +{ + uint res = DX = MAKE_INT_8(MASK_OUT_ABOVE_8(REG_IR)); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_d(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(DY); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_ai(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_AI_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_pi(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_PI_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_pd(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_PD_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_di(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_DI_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_ix(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AY_IX_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_aw(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AW_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_al(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_AL_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_pcdi(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_PCDI_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_pcix(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_PCIX_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_muls_16_i(void) +{ + uint* r_dst = &DX; + sint src = MAKE_INT_16(OPER_I_16()); + uint res = MASK_OUT_ABOVE_32( src * MAKE_INT_16(MASK_OUT_ABOVE_16(*r_dst))); + + UseMulsCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_d(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_16(DY); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_ai(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_AI_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_pi(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PI_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_pd(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PD_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_di(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_DI_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_ix(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_IX_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_aw(void) +{ + uint* r_dst = &DX; + uint src = OPER_AW_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_al(void) +{ + uint* r_dst = &DX; + uint src = OPER_AL_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_pcdi(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCDI_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_pcix(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCIX_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_mulu_16_i(void) +{ + uint* r_dst = &DX; + uint src = OPER_I_16(); + uint res = src * MASK_OUT_ABOVE_16(*r_dst); + + UseMuluCycles(src); + + *r_dst = res; + + FLAG_Z = res; + FLAG_N = NFLAG_32(res); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_nbcd_8_d(void) +{ + uint* r_dst = &DY; + uint dst = *r_dst; + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_di(void) +{ + uint ea = EA_AY_DI_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_aw(void) +{ + uint ea = EA_AW_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_nbcd_8_al(void) +{ + uint ea = EA_AL_8(); + uint dst = m68ki_read_8(ea); + uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1()); + + if(res != 0x9a) + { + FLAG_V = ~res; /* Undefined V behavior */ + + if((res & 0x0f) == 0xa) + res = (res & 0xf0) + 0x10; + + res = MASK_OUT_ABOVE_8(res); + + FLAG_V &= res; /* Undefined V behavior part II */ + + m68ki_write_8(ea, MASK_OUT_ABOVE_8(res)); + + FLAG_Z |= res; + FLAG_C = CFLAG_SET; + FLAG_X = XFLAG_SET; + } + else + { + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + FLAG_X = XFLAG_CLEAR; + } + FLAG_N = NFLAG_8(res); /* Undefined N behavior */ +} + + +static void m68k_op_neg_8_d(void) +{ + uint* r_dst = &DY; + uint res = 0 - MASK_OUT_ABOVE_8(*r_dst); + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = *r_dst & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_neg_8_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_8_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_8_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_8_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_8_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_8_di(void) +{ + uint ea = EA_AY_DI_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_8_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_8_aw(void) +{ + uint ea = EA_AW_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_8_al(void) +{ + uint ea = EA_AL_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_8(res); + FLAG_C = FLAG_X = CFLAG_8(res); + FLAG_V = src & res; + FLAG_Z = MASK_OUT_ABOVE_8(res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_neg_16_d(void) +{ + uint* r_dst = &DY; + uint res = 0 - MASK_OUT_ABOVE_16(*r_dst); + + FLAG_N = NFLAG_16(res); + FLAG_C = FLAG_X = CFLAG_16(res); + FLAG_V = (*r_dst & res)>>8; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_neg_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_16(res); + FLAG_C = FLAG_X = CFLAG_16(res); + FLAG_V = (src & res)>>8; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_neg_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_16(res); + FLAG_C = FLAG_X = CFLAG_16(res); + FLAG_V = (src & res)>>8; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_neg_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_16(res); + FLAG_C = FLAG_X = CFLAG_16(res); + FLAG_V = (src & res)>>8; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_neg_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_16(res); + FLAG_C = FLAG_X = CFLAG_16(res); + FLAG_V = (src & res)>>8; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_neg_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_16(res); + FLAG_C = FLAG_X = CFLAG_16(res); + FLAG_V = (src & res)>>8; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_neg_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_16(res); + FLAG_C = FLAG_X = CFLAG_16(res); + FLAG_V = (src & res)>>8; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_neg_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_16(res); + FLAG_C = FLAG_X = CFLAG_16(res); + FLAG_V = (src & res)>>8; + FLAG_Z = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_neg_32_d(void) +{ + uint* r_dst = &DY; + uint res = 0 - *r_dst; + + FLAG_N = NFLAG_32(res); + FLAG_C = FLAG_X = CFLAG_SUB_32(*r_dst, 0, res); + FLAG_V = (*r_dst & res)>>24; + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_neg_32_ai(void) +{ + uint ea = EA_AY_AI_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_32(res); + FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_neg_32_pi(void) +{ + uint ea = EA_AY_PI_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_32(res); + FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_neg_32_pd(void) +{ + uint ea = EA_AY_PD_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_32(res); + FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_neg_32_di(void) +{ + uint ea = EA_AY_DI_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_32(res); + FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_neg_32_ix(void) +{ + uint ea = EA_AY_IX_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_32(res); + FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_neg_32_aw(void) +{ + uint ea = EA_AW_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_32(res); + FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_neg_32_al(void) +{ + uint ea = EA_AL_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - src; + + FLAG_N = NFLAG_32(res); + FLAG_C = FLAG_X = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + FLAG_Z = MASK_OUT_ABOVE_32(res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_negx_8_d(void) +{ + uint* r_dst = &DY; + uint res = 0 - MASK_OUT_ABOVE_8(*r_dst) - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = *r_dst & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; +} + + +static void m68k_op_negx_8_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_8_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_8_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_8_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_8_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_8_di(void) +{ + uint ea = EA_AY_DI_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_8_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_8_aw(void) +{ + uint ea = EA_AW_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_8_al(void) +{ + uint ea = EA_AL_8(); + uint src = m68ki_read_8(ea); + uint res = 0 - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = src & res; + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_negx_16_d(void) +{ + uint* r_dst = &DY; + uint res = 0 - MASK_OUT_ABOVE_16(*r_dst) - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = (*r_dst & res)>>8; + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; +} + + +static void m68k_op_negx_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = (src & res)>>8; + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_negx_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = (src & res)>>8; + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_negx_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = (src & res)>>8; + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_negx_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = (src & res)>>8; + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_negx_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = (src & res)>>8; + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_negx_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = (src & res)>>8; + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_negx_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = 0 - MASK_OUT_ABOVE_16(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = (src & res)>>8; + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_negx_32_d(void) +{ + uint* r_dst = &DY; + uint res = 0 - MASK_OUT_ABOVE_32(*r_dst) - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(*r_dst, 0, res); + FLAG_V = (*r_dst & res)>>24; + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + *r_dst = res; +} + + +static void m68k_op_negx_32_ai(void) +{ + uint ea = EA_AY_AI_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_negx_32_pi(void) +{ + uint ea = EA_AY_PI_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_negx_32_pd(void) +{ + uint ea = EA_AY_PD_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_negx_32_di(void) +{ + uint ea = EA_AY_DI_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_negx_32_ix(void) +{ + uint ea = EA_AY_IX_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_negx_32_aw(void) +{ + uint ea = EA_AW_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_negx_32_al(void) +{ + uint ea = EA_AL_32(); + uint src = m68ki_read_32(ea); + uint res = 0 - MASK_OUT_ABOVE_32(src) - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, 0, res); + FLAG_V = (src & res)>>24; + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_nop(void) +{ +} + + +static void m68k_op_not_8_d(void) +{ + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_8(~*r_dst); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_di(void) +{ + uint ea = EA_AY_DI_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_aw(void) +{ + uint ea = EA_AW_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_8_al(void) +{ + uint ea = EA_AL_8(); + uint res = MASK_OUT_ABOVE_8(~m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_16_d(void) +{ + uint* r_dst = &DY; + uint res = MASK_OUT_ABOVE_16(~*r_dst); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_16_aw(void) +{ + uint ea = EA_AW_16(); + uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_16_al(void) +{ + uint ea = EA_AL_16(); + uint res = MASK_OUT_ABOVE_16(~m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_32_d(void) +{ + uint* r_dst = &DY; + uint res = *r_dst = MASK_OUT_ABOVE_32(~*r_dst); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_32_ai(void) +{ + uint ea = EA_AY_AI_32(); + uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_32_pi(void) +{ + uint ea = EA_AY_PI_32(); + uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_32_pd(void) +{ + uint ea = EA_AY_PD_32(); + uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_32_di(void) +{ + uint ea = EA_AY_DI_32(); + uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_32_ix(void) +{ + uint ea = EA_AY_IX_32(); + uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_32_aw(void) +{ + uint ea = EA_AW_32(); + uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_not_32_al(void) +{ + uint ea = EA_AL_32(); + uint res = MASK_OUT_ABOVE_32(~m68ki_read_32(ea)); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_d(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= MASK_OUT_ABOVE_8(DY))); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_ai(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_AI_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_pi(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_PI_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_pi7(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_A7_PI_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_pd(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_PD_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_pd7(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_A7_PD_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_di(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_DI_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_ix(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_AY_IX_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_aw(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_AW_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_al(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_AL_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_pcdi(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_PCDI_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_pcix(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_PCIX_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_er_i(void) +{ + uint res = MASK_OUT_ABOVE_8((DX |= OPER_I_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_d(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= MASK_OUT_ABOVE_16(DY))); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_ai(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_AI_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_pi(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_PI_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_pd(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_PD_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_di(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_DI_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_ix(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_AY_IX_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_aw(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_AW_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_al(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_AL_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_pcdi(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_PCDI_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_pcix(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_PCIX_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_er_i(void) +{ + uint res = MASK_OUT_ABOVE_16((DX |= OPER_I_16())); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_d(void) +{ + uint res = DX |= DY; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_ai(void) +{ + uint res = DX |= OPER_AY_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_pi(void) +{ + uint res = DX |= OPER_AY_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_pd(void) +{ + uint res = DX |= OPER_AY_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_di(void) +{ + uint res = DX |= OPER_AY_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_ix(void) +{ + uint res = DX |= OPER_AY_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_aw(void) +{ + uint res = DX |= OPER_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_al(void) +{ + uint res = DX |= OPER_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_pcdi(void) +{ + uint res = DX |= OPER_PCDI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_pcix(void) +{ + uint res = DX |= OPER_PCIX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_er_i(void) +{ + uint res = DX |= OPER_I_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_di(void) +{ + uint ea = EA_AY_DI_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_aw(void) +{ + uint ea = EA_AW_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_8_re_al(void) +{ + uint ea = EA_AL_8(); + uint res = MASK_OUT_ABOVE_8(DX | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_re_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_re_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_re_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_re_di(void) +{ + uint ea = EA_AY_DI_16(); + uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_re_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_re_aw(void) +{ + uint ea = EA_AW_16(); + uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_16_re_al(void) +{ + uint ea = EA_AL_16(); + uint res = MASK_OUT_ABOVE_16(DX | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_re_ai(void) +{ + uint ea = EA_AY_AI_32(); + uint res = DX | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_re_pi(void) +{ + uint ea = EA_AY_PI_32(); + uint res = DX | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_re_pd(void) +{ + uint ea = EA_AY_PD_32(); + uint res = DX | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_re_di(void) +{ + uint ea = EA_AY_DI_32(); + uint res = DX | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_re_ix(void) +{ + uint ea = EA_AY_IX_32(); + uint res = DX | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_re_aw(void) +{ + uint ea = EA_AW_32(); + uint res = DX | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_or_32_re_al(void) +{ + uint ea = EA_AL_32(); + uint res = DX | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_d(void) +{ + uint res = MASK_OUT_ABOVE_8((DY |= OPER_I_8())); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_ai(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_AI_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_pi(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PI_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_pi7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PI_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_pd(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PD_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_pd7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PD_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_di(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_DI_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_ix(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_IX_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_aw(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AW_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_8_al(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AL_8(); + uint res = MASK_OUT_ABOVE_8(src | m68ki_read_8(ea)); + + m68ki_write_8(ea, res); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY |= OPER_I_16()); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_ai(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_AI_16(); + uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_pi(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PI_16(); + uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_pd(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PD_16(); + uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_di(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_DI_16(); + uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_ix(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_IX_16(); + uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_aw(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AW_16(); + uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_al(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AL_16(); + uint res = MASK_OUT_ABOVE_16(src | m68ki_read_16(ea)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_32_d(void) +{ + uint res = DY |= OPER_I_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_32_ai(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_AI_32(); + uint res = src | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_32_pi(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PI_32(); + uint res = src | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_32_pd(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PD_32(); + uint res = src | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_32_di(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_DI_32(); + uint res = src | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_32_ix(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_IX_32(); + uint res = src | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_32_aw(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AW_32(); + uint res = src | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_32_al(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AL_32(); + uint res = src | m68ki_read_32(ea); + + m68ki_write_32(ea, res); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ori_16_toc(void) +{ + m68ki_set_ccr(m68ki_get_ccr() | OPER_I_16()); +} + + +static void m68k_op_ori_16_tos(void) +{ + if(FLAG_S) + { + uint src = OPER_I_16(); + m68ki_set_sr(m68ki_get_sr() | src); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_pea_32_ai(void) +{ + uint ea = EA_AY_AI_32(); + + m68ki_push_32(ea); +} + + +static void m68k_op_pea_32_di(void) +{ + uint ea = EA_AY_DI_32(); + + m68ki_push_32(ea); +} + + +static void m68k_op_pea_32_ix(void) +{ + uint ea = EA_AY_IX_32(); + + m68ki_push_32(ea); +} + + +static void m68k_op_pea_32_aw(void) +{ + uint ea = EA_AW_32(); + + m68ki_push_32(ea); +} + + +static void m68k_op_pea_32_al(void) +{ + uint ea = EA_AL_32(); + + m68ki_push_32(ea); +} + + +static void m68k_op_pea_32_pcdi(void) +{ + uint ea = EA_PCDI_32(); + + m68ki_push_32(ea); +} + + +static void m68k_op_pea_32_pcix(void) +{ + uint ea = EA_PCIX_32(); + + m68ki_push_32(ea); +} + + +static void m68k_op_reset(void) +{ + if(FLAG_S) + { + m68ki_output_reset() /* auto-disable (see m68kcpu.h) */ + USE_CYCLES(CYC_RESET); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_ror_8_s(void) +{ + uint* r_dst = &DY; + uint orig_shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint shift = orig_shift & 7; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = ROR_8(src, shift); + + if(orig_shift != 0) + USE_CYCLES(orig_shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = src << (9-orig_shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = ROR_16(src, shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src << (9-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_32_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint64 src = *r_dst; + uint res = ROR_32(src, shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = src << (9-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_8_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + uint shift = orig_shift & 7; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = ROR_8(src, shift); + + if(orig_shift != 0) + { + USE_CYCLES(orig_shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + FLAG_C = src << (8-((shift-1)&7)); + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_8(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + uint shift = orig_shift & 15; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = ROR_16(src, shift); + + if(orig_shift != 0) + { + USE_CYCLES(orig_shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + FLAG_C = (src >> ((shift - 1) & 15)) << 8; + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_16(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_32_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + uint shift = orig_shift & 31; + uint64 src = *r_dst; + uint res = ROR_32(src, shift); + + if(orig_shift != 0) + { + USE_CYCLES(orig_shift * CYC_SHIFT); + + *r_dst = res; + FLAG_C = (src >> ((shift - 1) & 31)) << 8; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_32(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_16(src, 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_16(src, 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_16(src, 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_16(src, 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_16(src, 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_16(src, 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_ror_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_16(src, 1); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src << 8; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_8_s(void) +{ + uint* r_dst = &DY; + uint orig_shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint shift = orig_shift & 7; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = ROL_8(src, shift); + + if(orig_shift != 0) + USE_CYCLES(orig_shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_C = src << orig_shift; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = ROL_16(src, shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src >> (8-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_32_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint64 src = *r_dst; + uint res = ROL_32(src, shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_C = src >> (24-shift); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_8_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + uint shift = orig_shift & 7; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = ROL_8(src, shift); + + if(orig_shift != 0) + { + USE_CYCLES(orig_shift * CYC_SHIFT); + + if(shift != 0) + { + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + FLAG_C = src << shift; + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + FLAG_C = (src & 1)<<8; + FLAG_N = NFLAG_8(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_8(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + uint shift = orig_shift & 15; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = MASK_OUT_ABOVE_16(ROL_16(src, shift)); + + if(orig_shift != 0) + { + USE_CYCLES(orig_shift * CYC_SHIFT); + + if(shift != 0) + { + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + FLAG_C = (src << shift) >> 8; + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + FLAG_C = (src & 1)<<8; + FLAG_N = NFLAG_16(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_16(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_32_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + uint shift = orig_shift & 31; + uint64 src = *r_dst; + uint res = ROL_32(src, shift); + + if(orig_shift != 0) + { + USE_CYCLES(orig_shift * CYC_SHIFT); + + *r_dst = res; + + FLAG_C = (src >> ((32 - shift) & 0x1f)) << 8; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = CFLAG_CLEAR; + FLAG_N = NFLAG_32(src); + FLAG_Z = src; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rol_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = MASK_OUT_ABOVE_16(ROL_16(src, 1)); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_C = src >> 7; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_8_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = ROR_9(src | (XFLAG_AS_1() << 8), shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res; + res = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_16_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_32_s(void) +{ +#if M68K_USE_64_BIT + + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint64 src = *r_dst; + uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + res = ROR_33_64(res, shift); + + FLAG_C = FLAG_X = res >> 24; + res = MASK_OUT_ABOVE_32(res); + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + #else -#define NUM_CPU_TYPES 1 + + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = *r_dst; + uint res = MASK_OUT_ABOVE_32((ROR_33(src, shift) & ~(1 << (32 - shift))) | (XFLAG_AS_1() << (32 - shift))); + uint new_x_flag = src & (1 << (shift - 1)); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = res; + + FLAG_C = FLAG_X = (new_x_flag != 0)<<8; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + +#endif +} + + +static void m68k_op_roxr_8_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + + if(orig_shift != 0) + { + uint shift = orig_shift % 9; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = ROR_9(src | (XFLAG_AS_1() << 8), shift); + + USE_CYCLES(orig_shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res; + res = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = FLAG_X; + FLAG_N = NFLAG_8(*r_dst); + FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_16_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + + if(orig_shift != 0) + { + uint shift = orig_shift % 17; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), shift); + + USE_CYCLES(orig_shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = FLAG_X; + FLAG_N = NFLAG_16(*r_dst); + FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_32_r(void) +{ +#if M68K_USE_64_BIT + + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + + if(orig_shift != 0) + { + uint shift = orig_shift % 33; + uint64 src = *r_dst; + uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); + + res = ROR_33_64(res, shift); + + USE_CYCLES(orig_shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res >> 24; + res = MASK_OUT_ABOVE_32(res); + + *r_dst = res; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = FLAG_X; + FLAG_N = NFLAG_32(*r_dst); + FLAG_Z = *r_dst; + FLAG_V = VFLAG_CLEAR; + +#else + + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + uint shift = orig_shift % 33; + uint src = *r_dst; + uint res = MASK_OUT_ABOVE_32((ROR_33(src, shift) & ~(1 << (32 - shift))) | (XFLAG_AS_1() << (32 - shift))); + uint new_x_flag = src & (1 << (shift - 1)); + + if(orig_shift != 0) + USE_CYCLES(orig_shift * CYC_SHIFT); + + if(shift != 0) + { + *r_dst = res; + FLAG_X = (new_x_flag != 0)<<8; + } + else + res = src; + FLAG_C = FLAG_X; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + +#endif +} + + +static void m68k_op_roxr_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxr_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = ROR_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_8_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = ROL_9(src | (XFLAG_AS_1() << 8), shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res; + res = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_16_s(void) +{ + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), shift); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_32_s(void) +{ +#if M68K_USE_64_BIT + + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint64 src = *r_dst; + uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + res = ROL_33_64(res, shift); + + FLAG_C = FLAG_X = res >> 24; + res = MASK_OUT_ABOVE_32(res); + + *r_dst = res; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + +#else + + uint* r_dst = &DY; + uint shift = (((REG_IR >> 9) - 1) & 7) + 1; + uint src = *r_dst; + uint res = MASK_OUT_ABOVE_32((ROL_33(src, shift) & ~(1 << (shift - 1))) | (XFLAG_AS_1() << (shift - 1))); + uint new_x_flag = src & (1 << (32 - shift)); + + if(shift != 0) + USE_CYCLES(shift * CYC_SHIFT); + + *r_dst = res; + + FLAG_C = FLAG_X = (new_x_flag != 0)<<8; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + +#endif +} + + +static void m68k_op_roxl_8_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + + + if(orig_shift != 0) + { + uint shift = orig_shift % 9; + uint src = MASK_OUT_ABOVE_8(*r_dst); + uint res = ROL_9(src | (XFLAG_AS_1() << 8), shift); + + USE_CYCLES(orig_shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res; + res = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = FLAG_X; + FLAG_N = NFLAG_8(*r_dst); + FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_16_r(void) +{ + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + + if(orig_shift != 0) + { + uint shift = orig_shift % 17; + uint src = MASK_OUT_ABOVE_16(*r_dst); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), shift); + + USE_CYCLES(orig_shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = FLAG_X; + FLAG_N = NFLAG_16(*r_dst); + FLAG_Z = MASK_OUT_ABOVE_16(*r_dst); + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_32_r(void) +{ +#if M68K_USE_64_BIT + + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + + if(orig_shift != 0) + { + uint shift = orig_shift % 33; + uint64 src = *r_dst; + uint64 res = src | (((uint64)XFLAG_AS_1()) << 32); + + res = ROL_33_64(res, shift); + + USE_CYCLES(orig_shift * CYC_SHIFT); + + FLAG_C = FLAG_X = res >> 24; + res = MASK_OUT_ABOVE_32(res); + + *r_dst = res; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + return; + } + + FLAG_C = FLAG_X; + FLAG_N = NFLAG_32(*r_dst); + FLAG_Z = *r_dst; + FLAG_V = VFLAG_CLEAR; + +#else + + uint* r_dst = &DY; + uint orig_shift = DX & 0x3f; + uint shift = orig_shift % 33; + uint src = *r_dst; + uint res = MASK_OUT_ABOVE_32((ROL_33(src, shift) & ~(1 << (shift - 1))) | (XFLAG_AS_1() << (shift - 1))); + uint new_x_flag = src & (1 << (32 - shift)); + + if(orig_shift != 0) + USE_CYCLES(orig_shift * CYC_SHIFT); + + if(shift != 0) + { + *r_dst = res; + FLAG_X = (new_x_flag != 0)<<8; + } + else + res = src; + FLAG_C = FLAG_X; + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + +#endif +} + + +static void m68k_op_roxl_16_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = m68ki_read_16(ea); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_16_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = m68ki_read_16(ea); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_16_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = m68ki_read_16(ea); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_16_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = m68ki_read_16(ea); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_16_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = m68ki_read_16(ea); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_16_aw(void) +{ + uint ea = EA_AW_16(); + uint src = m68ki_read_16(ea); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_roxl_16_al(void) +{ + uint ea = EA_AL_16(); + uint src = m68ki_read_16(ea); + uint res = ROL_17(src | (XFLAG_AS_1() << 16), 1); + + FLAG_C = FLAG_X = res >> 8; + res = MASK_OUT_ABOVE_16(res); + + m68ki_write_16(ea, res); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_rte_32(void) +{ + if(FLAG_S) + { + uint new_sr; + uint new_pc; + + new_sr = m68ki_pull_16(); + new_pc = m68ki_pull_32(); + m68ki_jump(new_pc); + m68ki_set_sr(new_sr); + +#if M68K_EMULATE_ADDRESS_ERROR + CPU_INSTR_MODE = INSTRUCTION_YES; + CPU_RUN_MODE = RUN_MODE_NORMAL; #endif -/* Build the opcode handler table */ -void m68ki_build_opcode_table(void); + return; + } + m68ki_exception_privilege_violation(); +} -extern void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */ -extern unsigned char m68ki_cycles[][0x10000]; + +static void m68k_op_rtr_32(void) +{ + m68ki_set_ccr(m68ki_pull_16()); + m68ki_jump(m68ki_pull_32()); +} + + +static void m68k_op_rts_32(void) +{ + m68ki_jump(m68ki_pull_32()); +} + + +static void m68k_op_sbcd_8_rr(void) +{ + uint* r_dst = &DX; + uint src = DY; + uint dst = *r_dst; + uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); + +// FLAG_V = ~res; /* Undefined V behavior */ + FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to assume cleared. */ + + if(res > 9) + res -= 6; + res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); + if(res > 0x99) + { + res += 0xa0; + FLAG_X = FLAG_C = CFLAG_SET; + FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ + } + else + FLAG_N = FLAG_X = FLAG_C = 0; + + res = MASK_OUT_ABOVE_8(res); + +// FLAG_V &= res; /* Undefined V behavior part II */ +// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + FLAG_Z |= res; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; +} + + +static void m68k_op_sbcd_8_mm_ax7(void) +{ + uint src = OPER_AY_PD_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); + +// FLAG_V = ~res; /* Undefined V behavior */ + FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ + + if(res > 9) + res -= 6; + res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); + if(res > 0x99) + { + res += 0xa0; + FLAG_X = FLAG_C = CFLAG_SET; + FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ + } + else + FLAG_N = FLAG_X = FLAG_C = 0; + + res = MASK_OUT_ABOVE_8(res); + +// FLAG_V &= res; /* Undefined V behavior part II */ +// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_sbcd_8_mm_ay7(void) +{ + uint src = OPER_A7_PD_8(); + uint ea = EA_AX_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); + +// FLAG_V = ~res; /* Undefined V behavior */ + FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ + + if(res > 9) + res -= 6; + res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); + if(res > 0x99) + { + res += 0xa0; + FLAG_X = FLAG_C = CFLAG_SET; + FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ + } + else + FLAG_N = FLAG_X = FLAG_C = 0; + + res = MASK_OUT_ABOVE_8(res); + +// FLAG_V &= res; /* Undefined V behavior part II */ +// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_sbcd_8_mm_axy7(void) +{ + uint src = OPER_A7_PD_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); + +// FLAG_V = ~res; /* Undefined V behavior */ + FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ + + if(res > 9) + res -= 6; + res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); + if(res > 0x99) + { + res += 0xa0; + FLAG_X = FLAG_C = CFLAG_SET; + FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ + } + else + FLAG_N = FLAG_X = FLAG_C = 0; + + res = MASK_OUT_ABOVE_8(res); + +// FLAG_V &= res; /* Undefined V behavior part II */ +// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_sbcd_8_mm(void) +{ + uint src = OPER_AY_PD_8(); + uint ea = EA_AX_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1(); + +// FLAG_V = ~res; /* Undefined V behavior */ + FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */ + + if(res > 9) + res -= 6; + res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src); + if(res > 0x99) + { + res += 0xa0; + FLAG_X = FLAG_C = CFLAG_SET; + FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */ + } + else + FLAG_N = FLAG_X = FLAG_C = 0; + + res = MASK_OUT_ABOVE_8(res); + +// FLAG_V &= res; /* Undefined V behavior part II */ +// FLAG_N = NFLAG_8(res); /* Undefined N behavior */ + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_st_8_d(void) +{ + DY |= 0xff; +} + + +static void m68k_op_st_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), 0xff); +} + + +static void m68k_op_st_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), 0xff); +} + + +static void m68k_op_st_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), 0xff); +} + + +static void m68k_op_st_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), 0xff); +} + + +static void m68k_op_st_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), 0xff); +} + + +static void m68k_op_st_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), 0xff); +} + + +static void m68k_op_st_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), 0xff); +} + + +static void m68k_op_st_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), 0xff); +} + + +static void m68k_op_st_8_al(void) +{ + m68ki_write_8(EA_AL_8(), 0xff); +} + + +static void m68k_op_sf_8_d(void) +{ + DY &= 0xffffff00; +} + + +static void m68k_op_sf_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), 0); +} + + +static void m68k_op_sf_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), 0); +} + + +static void m68k_op_sf_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), 0); +} + + +static void m68k_op_sf_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), 0); +} + + +static void m68k_op_sf_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), 0); +} + + +static void m68k_op_sf_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), 0); +} + + +static void m68k_op_sf_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), 0); +} + + +static void m68k_op_sf_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), 0); +} + + +static void m68k_op_sf_8_al(void) +{ + m68ki_write_8(EA_AL_8(), 0); +} + + +static void m68k_op_shi_8_d(void) +{ + if(COND_HI()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_sls_8_d(void) +{ + if(COND_LS()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_scc_8_d(void) +{ + if(COND_CC()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_scs_8_d(void) +{ + if(COND_CS()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_sne_8_d(void) +{ + if(COND_NE()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_seq_8_d(void) +{ + if(COND_EQ()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_svc_8_d(void) +{ + if(COND_VC()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_svs_8_d(void) +{ + if(COND_VS()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_spl_8_d(void) +{ + if(COND_PL()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_smi_8_d(void) +{ + if(COND_MI()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_sge_8_d(void) +{ + if(COND_GE()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_slt_8_d(void) +{ + if(COND_LT()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_sgt_8_d(void) +{ + if(COND_GT()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_sle_8_d(void) +{ + if(COND_LE()) + { + DY |= 0xff; + USE_CYCLES(CYC_SCC_R_TRUE); + return; + } + DY &= 0xffffff00; +} + + +static void m68k_op_shi_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_shi_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_shi_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_shi_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_shi_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_shi_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_shi_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_shi_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_shi_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_HI() ? 0xff : 0); +} + + +static void m68k_op_sls_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_sls_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_sls_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_sls_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_sls_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_sls_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_sls_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_sls_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_sls_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_LS() ? 0xff : 0); +} + + +static void m68k_op_scc_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scc_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scc_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scc_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scc_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scc_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scc_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scc_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scc_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_CC() ? 0xff : 0); +} + + +static void m68k_op_scs_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_scs_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_scs_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_scs_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_scs_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_scs_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_scs_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_scs_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_scs_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_CS() ? 0xff : 0); +} + + +static void m68k_op_sne_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_sne_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_sne_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_sne_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_sne_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_sne_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_sne_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_sne_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_sne_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_NE() ? 0xff : 0); +} + + +static void m68k_op_seq_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_seq_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_seq_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_seq_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_seq_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_seq_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_seq_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_seq_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_seq_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_EQ() ? 0xff : 0); +} + + +static void m68k_op_svc_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svc_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svc_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svc_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svc_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svc_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svc_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svc_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svc_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_VC() ? 0xff : 0); +} + + +static void m68k_op_svs_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_svs_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_svs_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_svs_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_svs_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_svs_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_svs_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_svs_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_svs_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_VS() ? 0xff : 0); +} + + +static void m68k_op_spl_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_spl_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_spl_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_spl_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_spl_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_spl_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_spl_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_spl_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_spl_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_PL() ? 0xff : 0); +} + + +static void m68k_op_smi_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_smi_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_smi_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_smi_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_smi_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_smi_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_smi_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_smi_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_smi_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_MI() ? 0xff : 0); +} + + +static void m68k_op_sge_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_sge_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_sge_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_sge_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_sge_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_sge_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_sge_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_sge_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_sge_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_GE() ? 0xff : 0); +} + + +static void m68k_op_slt_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_slt_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_slt_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_slt_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_slt_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_slt_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_slt_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_slt_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_slt_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_LT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sgt_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_GT() ? 0xff : 0); +} + + +static void m68k_op_sle_8_ai(void) +{ + m68ki_write_8(EA_AY_AI_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_sle_8_pi(void) +{ + m68ki_write_8(EA_AY_PI_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_sle_8_pi7(void) +{ + m68ki_write_8(EA_A7_PI_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_sle_8_pd(void) +{ + m68ki_write_8(EA_AY_PD_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_sle_8_pd7(void) +{ + m68ki_write_8(EA_A7_PD_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_sle_8_di(void) +{ + m68ki_write_8(EA_AY_DI_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_sle_8_ix(void) +{ + m68ki_write_8(EA_AY_IX_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_sle_8_aw(void) +{ + m68ki_write_8(EA_AW_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_sle_8_al(void) +{ + m68ki_write_8(EA_AL_8(), COND_LE() ? 0xff : 0); +} + + +static void m68k_op_stop(void) +{ + if(FLAG_S) + { + uint new_sr = OPER_I_16(); + CPU_STOPPED |= STOP_LEVEL_STOP; + m68ki_set_sr(new_sr); + END_CYCLES(end_cycles - 4*7); + return; + } + m68ki_exception_privilege_violation(); +} + + +static void m68k_op_sub_8_er_d(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_8(DY); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_ai(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_AI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_pi(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_pi7(void) +{ + uint* r_dst = &DX; + uint src = OPER_A7_PI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_pd(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PD_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_pd7(void) +{ + uint* r_dst = &DX; + uint src = OPER_A7_PD_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_di(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_DI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_ix(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_IX_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_aw(void) +{ + uint* r_dst = &DX; + uint src = OPER_AW_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_al(void) +{ + uint* r_dst = &DX; + uint src = OPER_AL_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_pcdi(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCDI_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_pcix(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCIX_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_8_er_i(void) +{ + uint* r_dst = &DX; + uint src = OPER_I_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_d(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_16(DY); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_a(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_16(AY); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_ai(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_AI_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_pi(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PI_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_pd(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PD_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_di(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_DI_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_ix(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_IX_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_aw(void) +{ + uint* r_dst = &DX; + uint src = OPER_AW_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_al(void) +{ + uint* r_dst = &DX; + uint src = OPER_AL_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_pcdi(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCDI_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_pcix(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCIX_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_16_er_i(void) +{ + uint* r_dst = &DX; + uint src = OPER_I_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_sub_32_er_d(void) +{ + uint* r_dst = &DX; + uint src = DY; + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_a(void) +{ + uint* r_dst = &DX; + uint src = AY; + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_ai(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_AI_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_pi(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PI_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_pd(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_PD_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_di(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_DI_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_ix(void) +{ + uint* r_dst = &DX; + uint src = OPER_AY_IX_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_aw(void) +{ + uint* r_dst = &DX; + uint src = OPER_AW_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_al(void) +{ + uint* r_dst = &DX; + uint src = OPER_AL_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_pcdi(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCDI_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_pcix(void) +{ + uint* r_dst = &DX; + uint src = OPER_PCIX_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_32_er_i(void) +{ + uint* r_dst = &DX; + uint src = OPER_I_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_sub_8_re_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_8_re_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_8_re_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_8_re_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_8_re_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_8_re_di(void) +{ + uint ea = EA_AY_DI_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_8_re_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_8_re_aw(void) +{ + uint ea = EA_AW_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_8_re_al(void) +{ + uint ea = EA_AL_8(); + uint src = MASK_OUT_ABOVE_8(DX); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_sub_16_re_ai(void) +{ + uint ea = EA_AY_AI_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_sub_16_re_pi(void) +{ + uint ea = EA_AY_PI_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_sub_16_re_pd(void) +{ + uint ea = EA_AY_PD_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_sub_16_re_di(void) +{ + uint ea = EA_AY_DI_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_sub_16_re_ix(void) +{ + uint ea = EA_AY_IX_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_sub_16_re_aw(void) +{ + uint ea = EA_AW_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_sub_16_re_al(void) +{ + uint ea = EA_AL_16(); + uint src = MASK_OUT_ABOVE_16(DX); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_sub_32_re_ai(void) +{ + uint ea = EA_AY_AI_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_sub_32_re_pi(void) +{ + uint ea = EA_AY_PI_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_sub_32_re_pd(void) +{ + uint ea = EA_AY_PD_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_sub_32_re_di(void) +{ + uint ea = EA_AY_DI_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_sub_32_re_ix(void) +{ + uint ea = EA_AY_IX_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_sub_32_re_aw(void) +{ + uint ea = EA_AW_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_sub_32_re_al(void) +{ + uint ea = EA_AL_32(); + uint src = DX; + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_suba_16_d(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(DY)); +} + + +static void m68k_op_suba_16_a(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - MAKE_INT_16(AY)); +} + + +static void m68k_op_suba_16_ai(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_AI_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_pi(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_PI_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_pd(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_PD_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_di(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_DI_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_ix(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AY_IX_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_aw(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AW_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_al(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_AL_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_pcdi(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_PCDI_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_pcix(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_PCIX_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_16_i(void) +{ + uint* r_dst = &AX; + uint src = MAKE_INT_16(OPER_I_16()); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_d(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - DY); +} + + +static void m68k_op_suba_32_a(void) +{ + uint* r_dst = &AX; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - AY); +} + + +static void m68k_op_suba_32_ai(void) +{ + uint* r_dst = &AX; + uint src = OPER_AY_AI_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_pi(void) +{ + uint* r_dst = &AX; + uint src = OPER_AY_PI_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_pd(void) +{ + uint* r_dst = &AX; + uint src = OPER_AY_PD_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_di(void) +{ + uint* r_dst = &AX; + uint src = OPER_AY_DI_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_ix(void) +{ + uint* r_dst = &AX; + uint src = OPER_AY_IX_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_aw(void) +{ + uint* r_dst = &AX; + uint src = OPER_AW_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_al(void) +{ + uint* r_dst = &AX; + uint src = OPER_AL_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_pcdi(void) +{ + uint* r_dst = &AX; + uint src = OPER_PCDI_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_pcix(void) +{ + uint* r_dst = &AX; + uint src = OPER_PCIX_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_suba_32_i(void) +{ + uint* r_dst = &AX; + uint src = OPER_I_32(); + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - src); +} + + +static void m68k_op_subi_8_d(void) +{ + uint* r_dst = &DY; + uint src = OPER_I_8(); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_subi_8_ai(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_AI_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_8_pi(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_8_pi7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_8_pd(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_8_pd7(void) +{ + uint src = OPER_I_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_8_di(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_DI_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_8_ix(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AY_IX_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_8_aw(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AW_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_8_al(void) +{ + uint src = OPER_I_8(); + uint ea = EA_AL_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subi_16_d(void) +{ + uint* r_dst = &DY; + uint src = OPER_I_16(); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_subi_16_ai(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_AI_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subi_16_pi(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PI_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subi_16_pd(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_PD_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subi_16_di(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_DI_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subi_16_ix(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AY_IX_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subi_16_aw(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AW_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subi_16_al(void) +{ + uint src = OPER_I_16(); + uint ea = EA_AL_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subi_32_d(void) +{ + uint* r_dst = &DY; + uint src = OPER_I_32(); + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_subi_32_ai(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_AI_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subi_32_pi(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PI_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subi_32_pd(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_PD_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subi_32_di(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_DI_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subi_32_ix(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AY_IX_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subi_32_aw(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AW_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subi_32_al(void) +{ + uint src = OPER_I_32(); + uint ea = EA_AL_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_d(void) +{ + uint* r_dst = &DY; + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | FLAG_Z; +} + + +static void m68k_op_subq_8_ai(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_AI_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_pi(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_pi7(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_A7_PI_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_pd(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_pd7(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_di(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_DI_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_ix(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_IX_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_aw(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AW_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_8_al(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AL_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src; + + FLAG_N = NFLAG_8(res); + FLAG_Z = MASK_OUT_ABOVE_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + m68ki_write_8(ea, FLAG_Z); +} + + +static void m68k_op_subq_16_d(void) +{ + uint* r_dst = &DY; + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | FLAG_Z; +} + + +static void m68k_op_subq_16_a(void) +{ + uint* r_dst = &AY; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - ((((REG_IR >> 9) - 1) & 7) + 1)); +} + + +static void m68k_op_subq_16_ai(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_AI_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subq_16_pi(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PI_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subq_16_pd(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PD_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subq_16_di(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_DI_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subq_16_ix(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_IX_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subq_16_aw(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AW_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subq_16_al(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AL_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src; + + FLAG_N = NFLAG_16(res); + FLAG_Z = MASK_OUT_ABOVE_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + m68ki_write_16(ea, FLAG_Z); +} + + +static void m68k_op_subq_32_d(void) +{ + uint* r_dst = &DY; + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint dst = *r_dst; + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + *r_dst = FLAG_Z; +} + + +static void m68k_op_subq_32_a(void) +{ + uint* r_dst = &AY; + + *r_dst = MASK_OUT_ABOVE_32(*r_dst - ((((REG_IR >> 9) - 1) & 7) + 1)); +} + + +static void m68k_op_subq_32_ai(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_AI_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subq_32_pi(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PI_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subq_32_pd(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_PD_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subq_32_di(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_DI_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subq_32_ix(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AY_IX_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subq_32_aw(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AW_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subq_32_al(void) +{ + uint src = (((REG_IR >> 9) - 1) & 7) + 1; + uint ea = EA_AL_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src; + + FLAG_N = NFLAG_32(res); + FLAG_Z = MASK_OUT_ABOVE_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + m68ki_write_32(ea, FLAG_Z); +} + + +static void m68k_op_subx_8_rr(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_8(DY); + uint dst = MASK_OUT_ABOVE_8(*r_dst); + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + *r_dst = MASK_OUT_BELOW_8(*r_dst) | res; +} + + +static void m68k_op_subx_16_rr(void) +{ + uint* r_dst = &DX; + uint src = MASK_OUT_ABOVE_16(DY); + uint dst = MASK_OUT_ABOVE_16(*r_dst); + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + *r_dst = MASK_OUT_BELOW_16(*r_dst) | res; +} + + +static void m68k_op_subx_32_rr(void) +{ + uint* r_dst = &DX; + uint src = DY; + uint dst = *r_dst; + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + *r_dst = res; +} + + +static void m68k_op_subx_8_mm_ax7(void) +{ + uint src = OPER_AY_PD_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_subx_8_mm_ay7(void) +{ + uint src = OPER_A7_PD_8(); + uint ea = EA_AX_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_subx_8_mm_axy7(void) +{ + uint src = OPER_A7_PD_8(); + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_subx_8_mm(void) +{ + uint src = OPER_AY_PD_8(); + uint ea = EA_AX_PD_8(); + uint dst = m68ki_read_8(ea); + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_8(res); + FLAG_X = FLAG_C = CFLAG_8(res); + FLAG_V = VFLAG_SUB_8(src, dst, res); + + res = MASK_OUT_ABOVE_8(res); + FLAG_Z |= res; + + m68ki_write_8(ea, res); +} + + +static void m68k_op_subx_16_mm(void) +{ + uint src = OPER_AY_PD_16(); + uint ea = EA_AX_PD_16(); + uint dst = m68ki_read_16(ea); + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_16(res); + FLAG_X = FLAG_C = CFLAG_16(res); + FLAG_V = VFLAG_SUB_16(src, dst, res); + + res = MASK_OUT_ABOVE_16(res); + FLAG_Z |= res; + + m68ki_write_16(ea, res); +} + + +static void m68k_op_subx_32_mm(void) +{ + uint src = OPER_AY_PD_32(); + uint ea = EA_AX_PD_32(); + uint dst = m68ki_read_32(ea); + uint res = dst - src - XFLAG_AS_1(); + + FLAG_N = NFLAG_32(res); + FLAG_X = FLAG_C = CFLAG_SUB_32(src, dst, res); + FLAG_V = VFLAG_SUB_32(src, dst, res); + + res = MASK_OUT_ABOVE_32(res); + FLAG_Z |= res; + + m68ki_write_32(ea, res); +} + + +static void m68k_op_swap_32(void) +{ + uint* r_dst = &DY; + + FLAG_Z = MASK_OUT_ABOVE_32(*r_dst<<16); + *r_dst = (*r_dst>>16) | FLAG_Z; + + FLAG_Z = *r_dst; + FLAG_N = NFLAG_32(*r_dst); + FLAG_C = CFLAG_CLEAR; + FLAG_V = VFLAG_CLEAR; +} + + +static void m68k_op_tas_8_d(void) +{ + uint* r_dst = &DY; + + FLAG_Z = MASK_OUT_ABOVE_8(*r_dst); + FLAG_N = NFLAG_8(*r_dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + *r_dst |= 0x80; +} + + +static void m68k_op_tas_8_ai(void) +{ + uint ea = EA_AY_AI_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_tas_8_pi(void) +{ + uint ea = EA_AY_PI_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_tas_8_pi7(void) +{ + uint ea = EA_A7_PI_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_tas_8_pd(void) +{ + uint ea = EA_AY_PD_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_tas_8_pd7(void) +{ + uint ea = EA_A7_PD_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_tas_8_di(void) +{ + uint ea = EA_AY_DI_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_tas_8_ix(void) +{ + uint ea = EA_AY_IX_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_tas_8_aw(void) +{ + uint ea = EA_AW_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_tas_8_al(void) +{ + uint ea = EA_AL_8(); + uint dst = m68ki_read_8(ea); + + FLAG_Z = dst; + FLAG_N = NFLAG_8(dst); + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; + + /* The Genesis/Megadrive games Gargoyles and Ex-Mutants need the TAS writeback + disabled in order to function properly. Some Amiga software may also rely + on this, but only when accessing specific addresses so additional functionality + will be needed. */ + uint allow_writeback = m68ki_tas_callback(); + + if (allow_writeback==1) m68ki_write_8(ea, dst | 0x80); +} + + +static void m68k_op_trap(void) +{ + /* Trap#n stacks exception frame type 0 */ + m68ki_exception_trapN(EXCEPTION_TRAP_BASE + (REG_IR & 0xf)); /* HJB 990403 */ +} + + +static void m68k_op_trapv(void) +{ + if(COND_VC()) + { + return; + } + m68ki_exception_trap(EXCEPTION_TRAPV); /* HJB 990403 */ +} + + +static void m68k_op_tst_8_d(void) +{ + uint res = MASK_OUT_ABOVE_8(DY); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_ai(void) +{ + uint res = OPER_AY_AI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_pi(void) +{ + uint res = OPER_AY_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_pi7(void) +{ + uint res = OPER_A7_PI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_pd(void) +{ + uint res = OPER_AY_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_pd7(void) +{ + uint res = OPER_A7_PD_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_di(void) +{ + uint res = OPER_AY_DI_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_ix(void) +{ + uint res = OPER_AY_IX_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_aw(void) +{ + uint res = OPER_AW_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_8_al(void) +{ + uint res = OPER_AL_8(); + + FLAG_N = NFLAG_8(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_16_d(void) +{ + uint res = MASK_OUT_ABOVE_16(DY); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_16_ai(void) +{ + uint res = OPER_AY_AI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_16_pi(void) +{ + uint res = OPER_AY_PI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_16_pd(void) +{ + uint res = OPER_AY_PD_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_16_di(void) +{ + uint res = OPER_AY_DI_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_16_ix(void) +{ + uint res = OPER_AY_IX_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_16_aw(void) +{ + uint res = OPER_AW_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_16_al(void) +{ + uint res = OPER_AL_16(); + + FLAG_N = NFLAG_16(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_32_d(void) +{ + uint res = DY; + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_32_ai(void) +{ + uint res = OPER_AY_AI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_32_pi(void) +{ + uint res = OPER_AY_PI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_32_pd(void) +{ + uint res = OPER_AY_PD_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_32_di(void) +{ + uint res = OPER_AY_DI_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_32_ix(void) +{ + uint res = OPER_AY_IX_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_32_aw(void) +{ + uint res = OPER_AW_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_tst_32_al(void) +{ + uint res = OPER_AL_32(); + + FLAG_N = NFLAG_32(res); + FLAG_Z = res; + FLAG_V = VFLAG_CLEAR; + FLAG_C = CFLAG_CLEAR; +} + + +static void m68k_op_unlk_32_a7(void) +{ + REG_A[7] = m68ki_read_32(REG_A[7]); +} + + +static void m68k_op_unlk_32(void) +{ + uint* r_dst = &AY; + + REG_A[7] = *r_dst; + *r_dst = m68ki_pull_32(); +} + + +/* ======================================================================== */ +/* ========================= OPCODE TABLE BUILDER ========================= */ +/* ======================================================================== */ + +/* This is used to generate the opcode handler jump table */ +typedef struct +{ + void (*opcode_handler)(void); /* handler function */ + unsigned int mask; /* mask on opcode */ + unsigned int match; /* what to match after masking */ + unsigned char cycles; /* cycles each cpu type takes */ +} opcode_handler_struct; + +/* opcode handler jump table */ +static void (*m68ki_instruction_jump_table[0x10000])(void); + +/* Opcode handler table */ +static const opcode_handler_struct m68k_opcode_handler_table[] = +{ +/* function mask match cyc */ + {m68k_op_1010 , 0xf000, 0xa000, 4}, + {m68k_op_1111 , 0xf000, 0xf000, 4}, + {m68k_op_moveq_32 , 0xf100, 0x7000, 4}, + {m68k_op_bra_8 , 0xff00, 0x6000, 10}, + {m68k_op_bsr_8 , 0xff00, 0x6100, 18}, + {m68k_op_bhi_8 , 0xff00, 0x6200, 10}, + {m68k_op_bls_8 , 0xff00, 0x6300, 10}, + {m68k_op_bcc_8 , 0xff00, 0x6400, 10}, + {m68k_op_bcs_8 , 0xff00, 0x6500, 10}, + {m68k_op_bne_8 , 0xff00, 0x6600, 10}, + {m68k_op_beq_8 , 0xff00, 0x6700, 10}, + {m68k_op_bvc_8 , 0xff00, 0x6800, 10}, + {m68k_op_bvs_8 , 0xff00, 0x6900, 10}, + {m68k_op_bpl_8 , 0xff00, 0x6a00, 10}, + {m68k_op_bmi_8 , 0xff00, 0x6b00, 10}, + {m68k_op_bge_8 , 0xff00, 0x6c00, 10}, + {m68k_op_blt_8 , 0xff00, 0x6d00, 10}, + {m68k_op_bgt_8 , 0xff00, 0x6e00, 10}, + {m68k_op_ble_8 , 0xff00, 0x6f00, 10}, + {m68k_op_btst_32_r_d , 0xf1f8, 0x0100, 6}, + {m68k_op_movep_16_er , 0xf1f8, 0x0108, 16}, + {m68k_op_btst_8_r_ai , 0xf1f8, 0x0110, 8}, + {m68k_op_btst_8_r_pi , 0xf1f8, 0x0118, 8}, + {m68k_op_btst_8_r_pd , 0xf1f8, 0x0120, 10}, + {m68k_op_btst_8_r_di , 0xf1f8, 0x0128, 12}, + {m68k_op_btst_8_r_ix , 0xf1f8, 0x0130, 14}, + {m68k_op_bchg_32_r_d , 0xf1f8, 0x0140, 8}, + {m68k_op_movep_32_er , 0xf1f8, 0x0148, 24}, + {m68k_op_bchg_8_r_ai , 0xf1f8, 0x0150, 12}, + {m68k_op_bchg_8_r_pi , 0xf1f8, 0x0158, 12}, + {m68k_op_bchg_8_r_pd , 0xf1f8, 0x0160, 14}, + {m68k_op_bchg_8_r_di , 0xf1f8, 0x0168, 16}, + {m68k_op_bchg_8_r_ix , 0xf1f8, 0x0170, 18}, + {m68k_op_bclr_32_r_d , 0xf1f8, 0x0180, 10}, + {m68k_op_movep_16_re , 0xf1f8, 0x0188, 16}, + {m68k_op_bclr_8_r_ai , 0xf1f8, 0x0190, 12}, + {m68k_op_bclr_8_r_pi , 0xf1f8, 0x0198, 12}, + {m68k_op_bclr_8_r_pd , 0xf1f8, 0x01a0, 14}, + {m68k_op_bclr_8_r_di , 0xf1f8, 0x01a8, 16}, + {m68k_op_bclr_8_r_ix , 0xf1f8, 0x01b0, 18}, + {m68k_op_bset_32_r_d , 0xf1f8, 0x01c0, 8}, + {m68k_op_movep_32_re , 0xf1f8, 0x01c8, 24}, + {m68k_op_bset_8_r_ai , 0xf1f8, 0x01d0, 12}, + {m68k_op_bset_8_r_pi , 0xf1f8, 0x01d8, 12}, + {m68k_op_bset_8_r_pd , 0xf1f8, 0x01e0, 14}, + {m68k_op_bset_8_r_di , 0xf1f8, 0x01e8, 16}, + {m68k_op_bset_8_r_ix , 0xf1f8, 0x01f0, 18}, + {m68k_op_move_8_d_d , 0xf1f8, 0x1000, 4}, + {m68k_op_move_8_d_ai , 0xf1f8, 0x1010, 8}, + {m68k_op_move_8_d_pi , 0xf1f8, 0x1018, 8}, + {m68k_op_move_8_d_pd , 0xf1f8, 0x1020, 10}, + {m68k_op_move_8_d_di , 0xf1f8, 0x1028, 12}, + {m68k_op_move_8_d_ix , 0xf1f8, 0x1030, 14}, + {m68k_op_move_8_ai_d , 0xf1f8, 0x1080, 8}, + {m68k_op_move_8_ai_ai , 0xf1f8, 0x1090, 12}, + {m68k_op_move_8_ai_pi , 0xf1f8, 0x1098, 12}, + {m68k_op_move_8_ai_pd , 0xf1f8, 0x10a0, 14}, + {m68k_op_move_8_ai_di , 0xf1f8, 0x10a8, 16}, + {m68k_op_move_8_ai_ix , 0xf1f8, 0x10b0, 18}, + {m68k_op_move_8_pi_d , 0xf1f8, 0x10c0, 8}, + {m68k_op_move_8_pi_ai , 0xf1f8, 0x10d0, 12}, + {m68k_op_move_8_pi_pi , 0xf1f8, 0x10d8, 12}, + {m68k_op_move_8_pi_pd , 0xf1f8, 0x10e0, 14}, + {m68k_op_move_8_pi_di , 0xf1f8, 0x10e8, 16}, + {m68k_op_move_8_pi_ix , 0xf1f8, 0x10f0, 18}, + {m68k_op_move_8_pd_d , 0xf1f8, 0x1100, 8}, + {m68k_op_move_8_pd_ai , 0xf1f8, 0x1110, 12}, + {m68k_op_move_8_pd_pi , 0xf1f8, 0x1118, 12}, + {m68k_op_move_8_pd_pd , 0xf1f8, 0x1120, 14}, + {m68k_op_move_8_pd_di , 0xf1f8, 0x1128, 16}, + {m68k_op_move_8_pd_ix , 0xf1f8, 0x1130, 18}, + {m68k_op_move_8_di_d , 0xf1f8, 0x1140, 12}, + {m68k_op_move_8_di_ai , 0xf1f8, 0x1150, 16}, + {m68k_op_move_8_di_pi , 0xf1f8, 0x1158, 16}, + {m68k_op_move_8_di_pd , 0xf1f8, 0x1160, 18}, + {m68k_op_move_8_di_di , 0xf1f8, 0x1168, 20}, + {m68k_op_move_8_di_ix , 0xf1f8, 0x1170, 22}, + {m68k_op_move_8_ix_d , 0xf1f8, 0x1180, 14}, + {m68k_op_move_8_ix_ai , 0xf1f8, 0x1190, 18}, + {m68k_op_move_8_ix_pi , 0xf1f8, 0x1198, 18}, + {m68k_op_move_8_ix_pd , 0xf1f8, 0x11a0, 20}, + {m68k_op_move_8_ix_di , 0xf1f8, 0x11a8, 22}, + {m68k_op_move_8_ix_ix , 0xf1f8, 0x11b0, 24}, + {m68k_op_move_32_d_d , 0xf1f8, 0x2000, 4}, + {m68k_op_move_32_d_a , 0xf1f8, 0x2008, 4}, + {m68k_op_move_32_d_ai , 0xf1f8, 0x2010, 12}, + {m68k_op_move_32_d_pi , 0xf1f8, 0x2018, 12}, + {m68k_op_move_32_d_pd , 0xf1f8, 0x2020, 14}, + {m68k_op_move_32_d_di , 0xf1f8, 0x2028, 16}, + {m68k_op_move_32_d_ix , 0xf1f8, 0x2030, 18}, + {m68k_op_movea_32_d , 0xf1f8, 0x2040, 4}, + {m68k_op_movea_32_a , 0xf1f8, 0x2048, 4}, + {m68k_op_movea_32_ai , 0xf1f8, 0x2050, 12}, + {m68k_op_movea_32_pi , 0xf1f8, 0x2058, 12}, + {m68k_op_movea_32_pd , 0xf1f8, 0x2060, 14}, + {m68k_op_movea_32_di , 0xf1f8, 0x2068, 16}, + {m68k_op_movea_32_ix , 0xf1f8, 0x2070, 18}, + {m68k_op_move_32_ai_d , 0xf1f8, 0x2080, 12}, + {m68k_op_move_32_ai_a , 0xf1f8, 0x2088, 12}, + {m68k_op_move_32_ai_ai , 0xf1f8, 0x2090, 20}, + {m68k_op_move_32_ai_pi , 0xf1f8, 0x2098, 20}, + {m68k_op_move_32_ai_pd , 0xf1f8, 0x20a0, 22}, + {m68k_op_move_32_ai_di , 0xf1f8, 0x20a8, 24}, + {m68k_op_move_32_ai_ix , 0xf1f8, 0x20b0, 26}, + {m68k_op_move_32_pi_d , 0xf1f8, 0x20c0, 12}, + {m68k_op_move_32_pi_a , 0xf1f8, 0x20c8, 12}, + {m68k_op_move_32_pi_ai , 0xf1f8, 0x20d0, 20}, + {m68k_op_move_32_pi_pi , 0xf1f8, 0x20d8, 20}, + {m68k_op_move_32_pi_pd , 0xf1f8, 0x20e0, 22}, + {m68k_op_move_32_pi_di , 0xf1f8, 0x20e8, 24}, + {m68k_op_move_32_pi_ix , 0xf1f8, 0x20f0, 26}, + {m68k_op_move_32_pd_d , 0xf1f8, 0x2100, 12}, + {m68k_op_move_32_pd_a , 0xf1f8, 0x2108, 12}, + {m68k_op_move_32_pd_ai , 0xf1f8, 0x2110, 20}, + {m68k_op_move_32_pd_pi , 0xf1f8, 0x2118, 20}, + {m68k_op_move_32_pd_pd , 0xf1f8, 0x2120, 22}, + {m68k_op_move_32_pd_di , 0xf1f8, 0x2128, 24}, + {m68k_op_move_32_pd_ix , 0xf1f8, 0x2130, 26}, + {m68k_op_move_32_di_d , 0xf1f8, 0x2140, 16}, + {m68k_op_move_32_di_a , 0xf1f8, 0x2148, 16}, + {m68k_op_move_32_di_ai , 0xf1f8, 0x2150, 24}, + {m68k_op_move_32_di_pi , 0xf1f8, 0x2158, 24}, + {m68k_op_move_32_di_pd , 0xf1f8, 0x2160, 26}, + {m68k_op_move_32_di_di , 0xf1f8, 0x2168, 28}, + {m68k_op_move_32_di_ix , 0xf1f8, 0x2170, 30}, + {m68k_op_move_32_ix_d , 0xf1f8, 0x2180, 18}, + {m68k_op_move_32_ix_a , 0xf1f8, 0x2188, 18}, + {m68k_op_move_32_ix_ai , 0xf1f8, 0x2190, 26}, + {m68k_op_move_32_ix_pi , 0xf1f8, 0x2198, 26}, + {m68k_op_move_32_ix_pd , 0xf1f8, 0x21a0, 28}, + {m68k_op_move_32_ix_di , 0xf1f8, 0x21a8, 30}, + {m68k_op_move_32_ix_ix , 0xf1f8, 0x21b0, 32}, + {m68k_op_move_16_d_d , 0xf1f8, 0x3000, 4}, + {m68k_op_move_16_d_a , 0xf1f8, 0x3008, 4}, + {m68k_op_move_16_d_ai , 0xf1f8, 0x3010, 8}, + {m68k_op_move_16_d_pi , 0xf1f8, 0x3018, 8}, + {m68k_op_move_16_d_pd , 0xf1f8, 0x3020, 10}, + {m68k_op_move_16_d_di , 0xf1f8, 0x3028, 12}, + {m68k_op_move_16_d_ix , 0xf1f8, 0x3030, 14}, + {m68k_op_movea_16_d , 0xf1f8, 0x3040, 4}, + {m68k_op_movea_16_a , 0xf1f8, 0x3048, 4}, + {m68k_op_movea_16_ai , 0xf1f8, 0x3050, 8}, + {m68k_op_movea_16_pi , 0xf1f8, 0x3058, 8}, + {m68k_op_movea_16_pd , 0xf1f8, 0x3060, 10}, + {m68k_op_movea_16_di , 0xf1f8, 0x3068, 12}, + {m68k_op_movea_16_ix , 0xf1f8, 0x3070, 14}, + {m68k_op_move_16_ai_d , 0xf1f8, 0x3080, 8}, + {m68k_op_move_16_ai_a , 0xf1f8, 0x3088, 8}, + {m68k_op_move_16_ai_ai , 0xf1f8, 0x3090, 12}, + {m68k_op_move_16_ai_pi , 0xf1f8, 0x3098, 12}, + {m68k_op_move_16_ai_pd , 0xf1f8, 0x30a0, 14}, + {m68k_op_move_16_ai_di , 0xf1f8, 0x30a8, 16}, + {m68k_op_move_16_ai_ix , 0xf1f8, 0x30b0, 18}, + {m68k_op_move_16_pi_d , 0xf1f8, 0x30c0, 8}, + {m68k_op_move_16_pi_a , 0xf1f8, 0x30c8, 8}, + {m68k_op_move_16_pi_ai , 0xf1f8, 0x30d0, 12}, + {m68k_op_move_16_pi_pi , 0xf1f8, 0x30d8, 12}, + {m68k_op_move_16_pi_pd , 0xf1f8, 0x30e0, 14}, + {m68k_op_move_16_pi_di , 0xf1f8, 0x30e8, 16}, + {m68k_op_move_16_pi_ix , 0xf1f8, 0x30f0, 18}, + {m68k_op_move_16_pd_d , 0xf1f8, 0x3100, 8}, + {m68k_op_move_16_pd_a , 0xf1f8, 0x3108, 8}, + {m68k_op_move_16_pd_ai , 0xf1f8, 0x3110, 12}, + {m68k_op_move_16_pd_pi , 0xf1f8, 0x3118, 12}, + {m68k_op_move_16_pd_pd , 0xf1f8, 0x3120, 14}, + {m68k_op_move_16_pd_di , 0xf1f8, 0x3128, 16}, + {m68k_op_move_16_pd_ix , 0xf1f8, 0x3130, 18}, + {m68k_op_move_16_di_d , 0xf1f8, 0x3140, 12}, + {m68k_op_move_16_di_a , 0xf1f8, 0x3148, 12}, + {m68k_op_move_16_di_ai , 0xf1f8, 0x3150, 16}, + {m68k_op_move_16_di_pi , 0xf1f8, 0x3158, 16}, + {m68k_op_move_16_di_pd , 0xf1f8, 0x3160, 18}, + {m68k_op_move_16_di_di , 0xf1f8, 0x3168, 20}, + {m68k_op_move_16_di_ix , 0xf1f8, 0x3170, 22}, + {m68k_op_move_16_ix_d , 0xf1f8, 0x3180, 14}, + {m68k_op_move_16_ix_a , 0xf1f8, 0x3188, 14}, + {m68k_op_move_16_ix_ai , 0xf1f8, 0x3190, 18}, + {m68k_op_move_16_ix_pi , 0xf1f8, 0x3198, 18}, + {m68k_op_move_16_ix_pd , 0xf1f8, 0x31a0, 20}, + {m68k_op_move_16_ix_di , 0xf1f8, 0x31a8, 22}, + {m68k_op_move_16_ix_ix , 0xf1f8, 0x31b0, 24}, + {m68k_op_chk_16_d , 0xf1f8, 0x4180, 10}, + {m68k_op_chk_16_ai , 0xf1f8, 0x4190, 14}, + {m68k_op_chk_16_pi , 0xf1f8, 0x4198, 14}, + {m68k_op_chk_16_pd , 0xf1f8, 0x41a0, 16}, + {m68k_op_chk_16_di , 0xf1f8, 0x41a8, 18}, + {m68k_op_chk_16_ix , 0xf1f8, 0x41b0, 20}, + {m68k_op_lea_32_ai , 0xf1f8, 0x41d0, 4}, + {m68k_op_lea_32_di , 0xf1f8, 0x41e8, 8}, + {m68k_op_lea_32_ix , 0xf1f8, 0x41f0, 12}, + {m68k_op_addq_8_d , 0xf1f8, 0x5000, 4}, + {m68k_op_addq_8_ai , 0xf1f8, 0x5010, 12}, + {m68k_op_addq_8_pi , 0xf1f8, 0x5018, 12}, + {m68k_op_addq_8_pd , 0xf1f8, 0x5020, 14}, + {m68k_op_addq_8_di , 0xf1f8, 0x5028, 16}, + {m68k_op_addq_8_ix , 0xf1f8, 0x5030, 18}, + {m68k_op_addq_16_d , 0xf1f8, 0x5040, 4}, + {m68k_op_addq_16_a , 0xf1f8, 0x5048, 4}, + {m68k_op_addq_16_ai , 0xf1f8, 0x5050, 12}, + {m68k_op_addq_16_pi , 0xf1f8, 0x5058, 12}, + {m68k_op_addq_16_pd , 0xf1f8, 0x5060, 14}, + {m68k_op_addq_16_di , 0xf1f8, 0x5068, 16}, + {m68k_op_addq_16_ix , 0xf1f8, 0x5070, 18}, + {m68k_op_addq_32_d , 0xf1f8, 0x5080, 8}, + {m68k_op_addq_32_a , 0xf1f8, 0x5088, 8}, + {m68k_op_addq_32_ai , 0xf1f8, 0x5090, 20}, + {m68k_op_addq_32_pi , 0xf1f8, 0x5098, 20}, + {m68k_op_addq_32_pd , 0xf1f8, 0x50a0, 22}, + {m68k_op_addq_32_di , 0xf1f8, 0x50a8, 24}, + {m68k_op_addq_32_ix , 0xf1f8, 0x50b0, 26}, + {m68k_op_subq_8_d , 0xf1f8, 0x5100, 4}, + {m68k_op_subq_8_ai , 0xf1f8, 0x5110, 12}, + {m68k_op_subq_8_pi , 0xf1f8, 0x5118, 12}, + {m68k_op_subq_8_pd , 0xf1f8, 0x5120, 14}, + {m68k_op_subq_8_di , 0xf1f8, 0x5128, 16}, + {m68k_op_subq_8_ix , 0xf1f8, 0x5130, 18}, + {m68k_op_subq_16_d , 0xf1f8, 0x5140, 4}, + {m68k_op_subq_16_a , 0xf1f8, 0x5148, 8}, + {m68k_op_subq_16_ai , 0xf1f8, 0x5150, 12}, + {m68k_op_subq_16_pi , 0xf1f8, 0x5158, 12}, + {m68k_op_subq_16_pd , 0xf1f8, 0x5160, 14}, + {m68k_op_subq_16_di , 0xf1f8, 0x5168, 16}, + {m68k_op_subq_16_ix , 0xf1f8, 0x5170, 18}, + {m68k_op_subq_32_d , 0xf1f8, 0x5180, 8}, + {m68k_op_subq_32_a , 0xf1f8, 0x5188, 8}, + {m68k_op_subq_32_ai , 0xf1f8, 0x5190, 20}, + {m68k_op_subq_32_pi , 0xf1f8, 0x5198, 20}, + {m68k_op_subq_32_pd , 0xf1f8, 0x51a0, 22}, + {m68k_op_subq_32_di , 0xf1f8, 0x51a8, 24}, + {m68k_op_subq_32_ix , 0xf1f8, 0x51b0, 26}, + {m68k_op_or_8_er_d , 0xf1f8, 0x8000, 4}, + {m68k_op_or_8_er_ai , 0xf1f8, 0x8010, 8}, + {m68k_op_or_8_er_pi , 0xf1f8, 0x8018, 8}, + {m68k_op_or_8_er_pd , 0xf1f8, 0x8020, 10}, + {m68k_op_or_8_er_di , 0xf1f8, 0x8028, 12}, + {m68k_op_or_8_er_ix , 0xf1f8, 0x8030, 14}, + {m68k_op_or_16_er_d , 0xf1f8, 0x8040, 4}, + {m68k_op_or_16_er_ai , 0xf1f8, 0x8050, 8}, + {m68k_op_or_16_er_pi , 0xf1f8, 0x8058, 8}, + {m68k_op_or_16_er_pd , 0xf1f8, 0x8060, 10}, + {m68k_op_or_16_er_di , 0xf1f8, 0x8068, 12}, + {m68k_op_or_16_er_ix , 0xf1f8, 0x8070, 14}, + {m68k_op_or_32_er_d , 0xf1f8, 0x8080, 8}, + {m68k_op_or_32_er_ai , 0xf1f8, 0x8090, 14}, + {m68k_op_or_32_er_pi , 0xf1f8, 0x8098, 14}, + {m68k_op_or_32_er_pd , 0xf1f8, 0x80a0, 16}, + {m68k_op_or_32_er_di , 0xf1f8, 0x80a8, 18}, + {m68k_op_or_32_er_ix , 0xf1f8, 0x80b0, 20}, + {m68k_op_divu_16_d , 0xf1f8, 0x80c0, 0}, + {m68k_op_divu_16_ai , 0xf1f8, 0x80d0, 4}, + {m68k_op_divu_16_pi , 0xf1f8, 0x80d8, 4}, + {m68k_op_divu_16_pd , 0xf1f8, 0x80e0, 6}, + {m68k_op_divu_16_di , 0xf1f8, 0x80e8, 8}, + {m68k_op_divu_16_ix , 0xf1f8, 0x80f0, 10}, + {m68k_op_sbcd_8_rr , 0xf1f8, 0x8100, 6}, + {m68k_op_sbcd_8_mm , 0xf1f8, 0x8108, 18}, + {m68k_op_or_8_re_ai , 0xf1f8, 0x8110, 12}, + {m68k_op_or_8_re_pi , 0xf1f8, 0x8118, 12}, + {m68k_op_or_8_re_pd , 0xf1f8, 0x8120, 14}, + {m68k_op_or_8_re_di , 0xf1f8, 0x8128, 16}, + {m68k_op_or_8_re_ix , 0xf1f8, 0x8130, 18}, + {m68k_op_or_16_re_ai , 0xf1f8, 0x8150, 12}, + {m68k_op_or_16_re_pi , 0xf1f8, 0x8158, 12}, + {m68k_op_or_16_re_pd , 0xf1f8, 0x8160, 14}, + {m68k_op_or_16_re_di , 0xf1f8, 0x8168, 16}, + {m68k_op_or_16_re_ix , 0xf1f8, 0x8170, 18}, + {m68k_op_or_32_re_ai , 0xf1f8, 0x8190, 20}, + {m68k_op_or_32_re_pi , 0xf1f8, 0x8198, 20}, + {m68k_op_or_32_re_pd , 0xf1f8, 0x81a0, 22}, + {m68k_op_or_32_re_di , 0xf1f8, 0x81a8, 24}, + {m68k_op_or_32_re_ix , 0xf1f8, 0x81b0, 26}, + {m68k_op_divs_16_d , 0xf1f8, 0x81c0, 0}, + {m68k_op_divs_16_ai , 0xf1f8, 0x81d0, 4}, + {m68k_op_divs_16_pi , 0xf1f8, 0x81d8, 4}, + {m68k_op_divs_16_pd , 0xf1f8, 0x81e0, 6}, + {m68k_op_divs_16_di , 0xf1f8, 0x81e8, 8}, + {m68k_op_divs_16_ix , 0xf1f8, 0x81f0, 10}, + {m68k_op_sub_8_er_d , 0xf1f8, 0x9000, 4}, + {m68k_op_sub_8_er_ai , 0xf1f8, 0x9010, 8}, + {m68k_op_sub_8_er_pi , 0xf1f8, 0x9018, 8}, + {m68k_op_sub_8_er_pd , 0xf1f8, 0x9020, 10}, + {m68k_op_sub_8_er_di , 0xf1f8, 0x9028, 12}, + {m68k_op_sub_8_er_ix , 0xf1f8, 0x9030, 14}, + {m68k_op_sub_16_er_d , 0xf1f8, 0x9040, 4}, + {m68k_op_sub_16_er_a , 0xf1f8, 0x9048, 4}, + {m68k_op_sub_16_er_ai , 0xf1f8, 0x9050, 8}, + {m68k_op_sub_16_er_pi , 0xf1f8, 0x9058, 8}, + {m68k_op_sub_16_er_pd , 0xf1f8, 0x9060, 10}, + {m68k_op_sub_16_er_di , 0xf1f8, 0x9068, 12}, + {m68k_op_sub_16_er_ix , 0xf1f8, 0x9070, 14}, + {m68k_op_sub_32_er_d , 0xf1f8, 0x9080, 8}, + {m68k_op_sub_32_er_a , 0xf1f8, 0x9088, 8}, + {m68k_op_sub_32_er_ai , 0xf1f8, 0x9090, 14}, + {m68k_op_sub_32_er_pi , 0xf1f8, 0x9098, 14}, + {m68k_op_sub_32_er_pd , 0xf1f8, 0x90a0, 16}, + {m68k_op_sub_32_er_di , 0xf1f8, 0x90a8, 18}, + {m68k_op_sub_32_er_ix , 0xf1f8, 0x90b0, 20}, + {m68k_op_suba_16_d , 0xf1f8, 0x90c0, 8}, + {m68k_op_suba_16_a , 0xf1f8, 0x90c8, 8}, + {m68k_op_suba_16_ai , 0xf1f8, 0x90d0, 12}, + {m68k_op_suba_16_pi , 0xf1f8, 0x90d8, 12}, + {m68k_op_suba_16_pd , 0xf1f8, 0x90e0, 14}, + {m68k_op_suba_16_di , 0xf1f8, 0x90e8, 16}, + {m68k_op_suba_16_ix , 0xf1f8, 0x90f0, 18}, + {m68k_op_subx_8_rr , 0xf1f8, 0x9100, 4}, + {m68k_op_subx_8_mm , 0xf1f8, 0x9108, 18}, + {m68k_op_sub_8_re_ai , 0xf1f8, 0x9110, 12}, + {m68k_op_sub_8_re_pi , 0xf1f8, 0x9118, 12}, + {m68k_op_sub_8_re_pd , 0xf1f8, 0x9120, 14}, + {m68k_op_sub_8_re_di , 0xf1f8, 0x9128, 16}, + {m68k_op_sub_8_re_ix , 0xf1f8, 0x9130, 18}, + {m68k_op_subx_16_rr , 0xf1f8, 0x9140, 4}, + {m68k_op_subx_16_mm , 0xf1f8, 0x9148, 18}, + {m68k_op_sub_16_re_ai , 0xf1f8, 0x9150, 12}, + {m68k_op_sub_16_re_pi , 0xf1f8, 0x9158, 12}, + {m68k_op_sub_16_re_pd , 0xf1f8, 0x9160, 14}, + {m68k_op_sub_16_re_di , 0xf1f8, 0x9168, 16}, + {m68k_op_sub_16_re_ix , 0xf1f8, 0x9170, 18}, + {m68k_op_subx_32_rr , 0xf1f8, 0x9180, 8}, + {m68k_op_subx_32_mm , 0xf1f8, 0x9188, 30}, + {m68k_op_sub_32_re_ai , 0xf1f8, 0x9190, 20}, + {m68k_op_sub_32_re_pi , 0xf1f8, 0x9198, 20}, + {m68k_op_sub_32_re_pd , 0xf1f8, 0x91a0, 22}, + {m68k_op_sub_32_re_di , 0xf1f8, 0x91a8, 24}, + {m68k_op_sub_32_re_ix , 0xf1f8, 0x91b0, 26}, + {m68k_op_suba_32_d , 0xf1f8, 0x91c0, 8}, + {m68k_op_suba_32_a , 0xf1f8, 0x91c8, 8}, + {m68k_op_suba_32_ai , 0xf1f8, 0x91d0, 14}, + {m68k_op_suba_32_pi , 0xf1f8, 0x91d8, 14}, + {m68k_op_suba_32_pd , 0xf1f8, 0x91e0, 16}, + {m68k_op_suba_32_di , 0xf1f8, 0x91e8, 18}, + {m68k_op_suba_32_ix , 0xf1f8, 0x91f0, 20}, + {m68k_op_cmp_8_d , 0xf1f8, 0xb000, 4}, + {m68k_op_cmp_8_ai , 0xf1f8, 0xb010, 8}, + {m68k_op_cmp_8_pi , 0xf1f8, 0xb018, 8}, + {m68k_op_cmp_8_pd , 0xf1f8, 0xb020, 10}, + {m68k_op_cmp_8_di , 0xf1f8, 0xb028, 12}, + {m68k_op_cmp_8_ix , 0xf1f8, 0xb030, 14}, + {m68k_op_cmp_16_d , 0xf1f8, 0xb040, 4}, + {m68k_op_cmp_16_a , 0xf1f8, 0xb048, 4}, + {m68k_op_cmp_16_ai , 0xf1f8, 0xb050, 8}, + {m68k_op_cmp_16_pi , 0xf1f8, 0xb058, 8}, + {m68k_op_cmp_16_pd , 0xf1f8, 0xb060, 10}, + {m68k_op_cmp_16_di , 0xf1f8, 0xb068, 12}, + {m68k_op_cmp_16_ix , 0xf1f8, 0xb070, 14}, + {m68k_op_cmp_32_d , 0xf1f8, 0xb080, 6}, + {m68k_op_cmp_32_a , 0xf1f8, 0xb088, 6}, + {m68k_op_cmp_32_ai , 0xf1f8, 0xb090, 14}, + {m68k_op_cmp_32_pi , 0xf1f8, 0xb098, 14}, + {m68k_op_cmp_32_pd , 0xf1f8, 0xb0a0, 16}, + {m68k_op_cmp_32_di , 0xf1f8, 0xb0a8, 18}, + {m68k_op_cmp_32_ix , 0xf1f8, 0xb0b0, 20}, + {m68k_op_cmpa_16_d , 0xf1f8, 0xb0c0, 6}, + {m68k_op_cmpa_16_a , 0xf1f8, 0xb0c8, 6}, + {m68k_op_cmpa_16_ai , 0xf1f8, 0xb0d0, 10}, + {m68k_op_cmpa_16_pi , 0xf1f8, 0xb0d8, 10}, + {m68k_op_cmpa_16_pd , 0xf1f8, 0xb0e0, 12}, + {m68k_op_cmpa_16_di , 0xf1f8, 0xb0e8, 14}, + {m68k_op_cmpa_16_ix , 0xf1f8, 0xb0f0, 16}, + {m68k_op_eor_8_d , 0xf1f8, 0xb100, 4}, + {m68k_op_cmpm_8 , 0xf1f8, 0xb108, 12}, + {m68k_op_eor_8_ai , 0xf1f8, 0xb110, 12}, + {m68k_op_eor_8_pi , 0xf1f8, 0xb118, 12}, + {m68k_op_eor_8_pd , 0xf1f8, 0xb120, 14}, + {m68k_op_eor_8_di , 0xf1f8, 0xb128, 16}, + {m68k_op_eor_8_ix , 0xf1f8, 0xb130, 18}, + {m68k_op_eor_16_d , 0xf1f8, 0xb140, 4}, + {m68k_op_cmpm_16 , 0xf1f8, 0xb148, 12}, + {m68k_op_eor_16_ai , 0xf1f8, 0xb150, 12}, + {m68k_op_eor_16_pi , 0xf1f8, 0xb158, 12}, + {m68k_op_eor_16_pd , 0xf1f8, 0xb160, 14}, + {m68k_op_eor_16_di , 0xf1f8, 0xb168, 16}, + {m68k_op_eor_16_ix , 0xf1f8, 0xb170, 18}, + {m68k_op_eor_32_d , 0xf1f8, 0xb180, 8}, + {m68k_op_cmpm_32 , 0xf1f8, 0xb188, 20}, + {m68k_op_eor_32_ai , 0xf1f8, 0xb190, 20}, + {m68k_op_eor_32_pi , 0xf1f8, 0xb198, 20}, + {m68k_op_eor_32_pd , 0xf1f8, 0xb1a0, 22}, + {m68k_op_eor_32_di , 0xf1f8, 0xb1a8, 24}, + {m68k_op_eor_32_ix , 0xf1f8, 0xb1b0, 26}, + {m68k_op_cmpa_32_d , 0xf1f8, 0xb1c0, 6}, + {m68k_op_cmpa_32_a , 0xf1f8, 0xb1c8, 6}, + {m68k_op_cmpa_32_ai , 0xf1f8, 0xb1d0, 14}, + {m68k_op_cmpa_32_pi , 0xf1f8, 0xb1d8, 14}, + {m68k_op_cmpa_32_pd , 0xf1f8, 0xb1e0, 16}, + {m68k_op_cmpa_32_di , 0xf1f8, 0xb1e8, 18}, + {m68k_op_cmpa_32_ix , 0xf1f8, 0xb1f0, 20}, + {m68k_op_and_8_er_d , 0xf1f8, 0xc000, 4}, + {m68k_op_and_8_er_ai , 0xf1f8, 0xc010, 8}, + {m68k_op_and_8_er_pi , 0xf1f8, 0xc018, 8}, + {m68k_op_and_8_er_pd , 0xf1f8, 0xc020, 10}, + {m68k_op_and_8_er_di , 0xf1f8, 0xc028, 12}, + {m68k_op_and_8_er_ix , 0xf1f8, 0xc030, 14}, + {m68k_op_and_16_er_d , 0xf1f8, 0xc040, 4}, + {m68k_op_and_16_er_ai , 0xf1f8, 0xc050, 8}, + {m68k_op_and_16_er_pi , 0xf1f8, 0xc058, 8}, + {m68k_op_and_16_er_pd , 0xf1f8, 0xc060, 10}, + {m68k_op_and_16_er_di , 0xf1f8, 0xc068, 12}, + {m68k_op_and_16_er_ix , 0xf1f8, 0xc070, 14}, + {m68k_op_and_32_er_d , 0xf1f8, 0xc080, 8}, + {m68k_op_and_32_er_ai , 0xf1f8, 0xc090, 14}, + {m68k_op_and_32_er_pi , 0xf1f8, 0xc098, 14}, + {m68k_op_and_32_er_pd , 0xf1f8, 0xc0a0, 16}, + {m68k_op_and_32_er_di , 0xf1f8, 0xc0a8, 18}, + {m68k_op_and_32_er_ix , 0xf1f8, 0xc0b0, 20}, + {m68k_op_mulu_16_d , 0xf1f8, 0xc0c0, 0}, + {m68k_op_mulu_16_ai , 0xf1f8, 0xc0d0, 4}, + {m68k_op_mulu_16_pi , 0xf1f8, 0xc0d8, 4}, + {m68k_op_mulu_16_pd , 0xf1f8, 0xc0e0, 6}, + {m68k_op_mulu_16_di , 0xf1f8, 0xc0e8, 8}, + {m68k_op_mulu_16_ix , 0xf1f8, 0xc0f0, 10}, + {m68k_op_abcd_8_rr , 0xf1f8, 0xc100, 6}, + {m68k_op_abcd_8_mm , 0xf1f8, 0xc108, 18}, + {m68k_op_and_8_re_ai , 0xf1f8, 0xc110, 12}, + {m68k_op_and_8_re_pi , 0xf1f8, 0xc118, 12}, + {m68k_op_and_8_re_pd , 0xf1f8, 0xc120, 14}, + {m68k_op_and_8_re_di , 0xf1f8, 0xc128, 16}, + {m68k_op_and_8_re_ix , 0xf1f8, 0xc130, 18}, + {m68k_op_exg_32_dd , 0xf1f8, 0xc140, 6}, + {m68k_op_exg_32_aa , 0xf1f8, 0xc148, 6}, + {m68k_op_and_16_re_ai , 0xf1f8, 0xc150, 12}, + {m68k_op_and_16_re_pi , 0xf1f8, 0xc158, 12}, + {m68k_op_and_16_re_pd , 0xf1f8, 0xc160, 14}, + {m68k_op_and_16_re_di , 0xf1f8, 0xc168, 16}, + {m68k_op_and_16_re_ix , 0xf1f8, 0xc170, 18}, + {m68k_op_exg_32_da , 0xf1f8, 0xc188, 6}, + {m68k_op_and_32_re_ai , 0xf1f8, 0xc190, 20}, + {m68k_op_and_32_re_pi , 0xf1f8, 0xc198, 20}, + {m68k_op_and_32_re_pd , 0xf1f8, 0xc1a0, 22}, + {m68k_op_and_32_re_di , 0xf1f8, 0xc1a8, 24}, + {m68k_op_and_32_re_ix , 0xf1f8, 0xc1b0, 26}, + {m68k_op_muls_16_d , 0xf1f8, 0xc1c0, 0}, + {m68k_op_muls_16_ai , 0xf1f8, 0xc1d0, 4}, + {m68k_op_muls_16_pi , 0xf1f8, 0xc1d8, 4}, + {m68k_op_muls_16_pd , 0xf1f8, 0xc1e0, 6}, + {m68k_op_muls_16_di , 0xf1f8, 0xc1e8, 8}, + {m68k_op_muls_16_ix , 0xf1f8, 0xc1f0, 10}, + {m68k_op_add_8_er_d , 0xf1f8, 0xd000, 4}, + {m68k_op_add_8_er_ai , 0xf1f8, 0xd010, 8}, + {m68k_op_add_8_er_pi , 0xf1f8, 0xd018, 8}, + {m68k_op_add_8_er_pd , 0xf1f8, 0xd020, 10}, + {m68k_op_add_8_er_di , 0xf1f8, 0xd028, 12}, + {m68k_op_add_8_er_ix , 0xf1f8, 0xd030, 14}, + {m68k_op_add_16_er_d , 0xf1f8, 0xd040, 4}, + {m68k_op_add_16_er_a , 0xf1f8, 0xd048, 4}, + {m68k_op_add_16_er_ai , 0xf1f8, 0xd050, 8}, + {m68k_op_add_16_er_pi , 0xf1f8, 0xd058, 8}, + {m68k_op_add_16_er_pd , 0xf1f8, 0xd060, 10}, + {m68k_op_add_16_er_di , 0xf1f8, 0xd068, 12}, + {m68k_op_add_16_er_ix , 0xf1f8, 0xd070, 14}, + {m68k_op_add_32_er_d , 0xf1f8, 0xd080, 8}, + {m68k_op_add_32_er_a , 0xf1f8, 0xd088, 8}, + {m68k_op_add_32_er_ai , 0xf1f8, 0xd090, 14}, + {m68k_op_add_32_er_pi , 0xf1f8, 0xd098, 14}, + {m68k_op_add_32_er_pd , 0xf1f8, 0xd0a0, 16}, + {m68k_op_add_32_er_di , 0xf1f8, 0xd0a8, 18}, + {m68k_op_add_32_er_ix , 0xf1f8, 0xd0b0, 20}, + {m68k_op_adda_16_d , 0xf1f8, 0xd0c0, 8}, + {m68k_op_adda_16_a , 0xf1f8, 0xd0c8, 8}, + {m68k_op_adda_16_ai , 0xf1f8, 0xd0d0, 12}, + {m68k_op_adda_16_pi , 0xf1f8, 0xd0d8, 12}, + {m68k_op_adda_16_pd , 0xf1f8, 0xd0e0, 14}, + {m68k_op_adda_16_di , 0xf1f8, 0xd0e8, 16}, + {m68k_op_adda_16_ix , 0xf1f8, 0xd0f0, 18}, + {m68k_op_addx_8_rr , 0xf1f8, 0xd100, 4}, + {m68k_op_addx_8_mm , 0xf1f8, 0xd108, 18}, + {m68k_op_add_8_re_ai , 0xf1f8, 0xd110, 12}, + {m68k_op_add_8_re_pi , 0xf1f8, 0xd118, 12}, + {m68k_op_add_8_re_pd , 0xf1f8, 0xd120, 14}, + {m68k_op_add_8_re_di , 0xf1f8, 0xd128, 16}, + {m68k_op_add_8_re_ix , 0xf1f8, 0xd130, 18}, + {m68k_op_addx_16_rr , 0xf1f8, 0xd140, 4}, + {m68k_op_addx_16_mm , 0xf1f8, 0xd148, 18}, + {m68k_op_add_16_re_ai , 0xf1f8, 0xd150, 12}, + {m68k_op_add_16_re_pi , 0xf1f8, 0xd158, 12}, + {m68k_op_add_16_re_pd , 0xf1f8, 0xd160, 14}, + {m68k_op_add_16_re_di , 0xf1f8, 0xd168, 16}, + {m68k_op_add_16_re_ix , 0xf1f8, 0xd170, 18}, + {m68k_op_addx_32_rr , 0xf1f8, 0xd180, 8}, + {m68k_op_addx_32_mm , 0xf1f8, 0xd188, 30}, + {m68k_op_add_32_re_ai , 0xf1f8, 0xd190, 20}, + {m68k_op_add_32_re_pi , 0xf1f8, 0xd198, 20}, + {m68k_op_add_32_re_pd , 0xf1f8, 0xd1a0, 22}, + {m68k_op_add_32_re_di , 0xf1f8, 0xd1a8, 24}, + {m68k_op_add_32_re_ix , 0xf1f8, 0xd1b0, 26}, + {m68k_op_adda_32_d , 0xf1f8, 0xd1c0, 8}, + {m68k_op_adda_32_a , 0xf1f8, 0xd1c8, 8}, + {m68k_op_adda_32_ai , 0xf1f8, 0xd1d0, 14}, + {m68k_op_adda_32_pi , 0xf1f8, 0xd1d8, 14}, + {m68k_op_adda_32_pd , 0xf1f8, 0xd1e0, 16}, + {m68k_op_adda_32_di , 0xf1f8, 0xd1e8, 18}, + {m68k_op_adda_32_ix , 0xf1f8, 0xd1f0, 20}, + {m68k_op_asr_8_s , 0xf1f8, 0xe000, 6}, + {m68k_op_lsr_8_s , 0xf1f8, 0xe008, 6}, + {m68k_op_roxr_8_s , 0xf1f8, 0xe010, 6}, + {m68k_op_ror_8_s , 0xf1f8, 0xe018, 6}, + {m68k_op_asr_8_r , 0xf1f8, 0xe020, 6}, + {m68k_op_lsr_8_r , 0xf1f8, 0xe028, 6}, + {m68k_op_roxr_8_r , 0xf1f8, 0xe030, 6}, + {m68k_op_ror_8_r , 0xf1f8, 0xe038, 6}, + {m68k_op_asr_16_s , 0xf1f8, 0xe040, 6}, + {m68k_op_lsr_16_s , 0xf1f8, 0xe048, 6}, + {m68k_op_roxr_16_s , 0xf1f8, 0xe050, 6}, + {m68k_op_ror_16_s , 0xf1f8, 0xe058, 6}, + {m68k_op_asr_16_r , 0xf1f8, 0xe060, 6}, + {m68k_op_lsr_16_r , 0xf1f8, 0xe068, 6}, + {m68k_op_roxr_16_r , 0xf1f8, 0xe070, 6}, + {m68k_op_ror_16_r , 0xf1f8, 0xe078, 6}, + {m68k_op_asr_32_s , 0xf1f8, 0xe080, 8}, + {m68k_op_lsr_32_s , 0xf1f8, 0xe088, 8}, + {m68k_op_roxr_32_s , 0xf1f8, 0xe090, 8}, + {m68k_op_ror_32_s , 0xf1f8, 0xe098, 8}, + {m68k_op_asr_32_r , 0xf1f8, 0xe0a0, 8}, + {m68k_op_lsr_32_r , 0xf1f8, 0xe0a8, 8}, + {m68k_op_roxr_32_r , 0xf1f8, 0xe0b0, 8}, + {m68k_op_ror_32_r , 0xf1f8, 0xe0b8, 8}, + {m68k_op_asl_8_s , 0xf1f8, 0xe100, 6}, + {m68k_op_lsl_8_s , 0xf1f8, 0xe108, 6}, + {m68k_op_roxl_8_s , 0xf1f8, 0xe110, 6}, + {m68k_op_rol_8_s , 0xf1f8, 0xe118, 6}, + {m68k_op_asl_8_r , 0xf1f8, 0xe120, 6}, + {m68k_op_lsl_8_r , 0xf1f8, 0xe128, 6}, + {m68k_op_roxl_8_r , 0xf1f8, 0xe130, 6}, + {m68k_op_rol_8_r , 0xf1f8, 0xe138, 6}, + {m68k_op_asl_16_s , 0xf1f8, 0xe140, 6}, + {m68k_op_lsl_16_s , 0xf1f8, 0xe148, 6}, + {m68k_op_roxl_16_s , 0xf1f8, 0xe150, 6}, + {m68k_op_rol_16_s , 0xf1f8, 0xe158, 6}, + {m68k_op_asl_16_r , 0xf1f8, 0xe160, 6}, + {m68k_op_lsl_16_r , 0xf1f8, 0xe168, 6}, + {m68k_op_roxl_16_r , 0xf1f8, 0xe170, 6}, + {m68k_op_rol_16_r , 0xf1f8, 0xe178, 6}, + {m68k_op_asl_32_s , 0xf1f8, 0xe180, 8}, + {m68k_op_lsl_32_s , 0xf1f8, 0xe188, 8}, + {m68k_op_roxl_32_s , 0xf1f8, 0xe190, 8}, + {m68k_op_rol_32_s , 0xf1f8, 0xe198, 8}, + {m68k_op_asl_32_r , 0xf1f8, 0xe1a0, 8}, + {m68k_op_lsl_32_r , 0xf1f8, 0xe1a8, 8}, + {m68k_op_roxl_32_r , 0xf1f8, 0xe1b0, 8}, + {m68k_op_rol_32_r , 0xf1f8, 0xe1b8, 8}, + {m68k_op_trap , 0xfff0, 0x4e40, 4}, + {m68k_op_btst_8_r_pi7 , 0xf1ff, 0x011f, 8}, + {m68k_op_btst_8_r_pd7 , 0xf1ff, 0x0127, 10}, + {m68k_op_btst_8_r_aw , 0xf1ff, 0x0138, 12}, + {m68k_op_btst_8_r_al , 0xf1ff, 0x0139, 16}, + {m68k_op_btst_8_r_pcdi , 0xf1ff, 0x013a, 12}, + {m68k_op_btst_8_r_pcix , 0xf1ff, 0x013b, 14}, + {m68k_op_btst_8_r_i , 0xf1ff, 0x013c, 8}, + {m68k_op_bchg_8_r_pi7 , 0xf1ff, 0x015f, 12}, + {m68k_op_bchg_8_r_pd7 , 0xf1ff, 0x0167, 14}, + {m68k_op_bchg_8_r_aw , 0xf1ff, 0x0178, 16}, + {m68k_op_bchg_8_r_al , 0xf1ff, 0x0179, 20}, + {m68k_op_bclr_8_r_pi7 , 0xf1ff, 0x019f, 12}, + {m68k_op_bclr_8_r_pd7 , 0xf1ff, 0x01a7, 14}, + {m68k_op_bclr_8_r_aw , 0xf1ff, 0x01b8, 16}, + {m68k_op_bclr_8_r_al , 0xf1ff, 0x01b9, 20}, + {m68k_op_bset_8_r_pi7 , 0xf1ff, 0x01df, 12}, + {m68k_op_bset_8_r_pd7 , 0xf1ff, 0x01e7, 14}, + {m68k_op_bset_8_r_aw , 0xf1ff, 0x01f8, 16}, + {m68k_op_bset_8_r_al , 0xf1ff, 0x01f9, 20}, + {m68k_op_move_8_d_pi7 , 0xf1ff, 0x101f, 8}, + {m68k_op_move_8_d_pd7 , 0xf1ff, 0x1027, 10}, + {m68k_op_move_8_d_aw , 0xf1ff, 0x1038, 12}, + {m68k_op_move_8_d_al , 0xf1ff, 0x1039, 16}, + {m68k_op_move_8_d_pcdi , 0xf1ff, 0x103a, 12}, + {m68k_op_move_8_d_pcix , 0xf1ff, 0x103b, 14}, + {m68k_op_move_8_d_i , 0xf1ff, 0x103c, 8}, + {m68k_op_move_8_ai_pi7 , 0xf1ff, 0x109f, 12}, + {m68k_op_move_8_ai_pd7 , 0xf1ff, 0x10a7, 14}, + {m68k_op_move_8_ai_aw , 0xf1ff, 0x10b8, 16}, + {m68k_op_move_8_ai_al , 0xf1ff, 0x10b9, 20}, + {m68k_op_move_8_ai_pcdi , 0xf1ff, 0x10ba, 16}, + {m68k_op_move_8_ai_pcix , 0xf1ff, 0x10bb, 18}, + {m68k_op_move_8_ai_i , 0xf1ff, 0x10bc, 12}, + {m68k_op_move_8_pi_pi7 , 0xf1ff, 0x10df, 12}, + {m68k_op_move_8_pi_pd7 , 0xf1ff, 0x10e7, 14}, + {m68k_op_move_8_pi_aw , 0xf1ff, 0x10f8, 16}, + {m68k_op_move_8_pi_al , 0xf1ff, 0x10f9, 20}, + {m68k_op_move_8_pi_pcdi , 0xf1ff, 0x10fa, 16}, + {m68k_op_move_8_pi_pcix , 0xf1ff, 0x10fb, 18}, + {m68k_op_move_8_pi_i , 0xf1ff, 0x10fc, 12}, + {m68k_op_move_8_pd_pi7 , 0xf1ff, 0x111f, 12}, + {m68k_op_move_8_pd_pd7 , 0xf1ff, 0x1127, 14}, + {m68k_op_move_8_pd_aw , 0xf1ff, 0x1138, 16}, + {m68k_op_move_8_pd_al , 0xf1ff, 0x1139, 20}, + {m68k_op_move_8_pd_pcdi , 0xf1ff, 0x113a, 16}, + {m68k_op_move_8_pd_pcix , 0xf1ff, 0x113b, 18}, + {m68k_op_move_8_pd_i , 0xf1ff, 0x113c, 12}, + {m68k_op_move_8_di_pi7 , 0xf1ff, 0x115f, 16}, + {m68k_op_move_8_di_pd7 , 0xf1ff, 0x1167, 18}, + {m68k_op_move_8_di_aw , 0xf1ff, 0x1178, 20}, + {m68k_op_move_8_di_al , 0xf1ff, 0x1179, 24}, + {m68k_op_move_8_di_pcdi , 0xf1ff, 0x117a, 20}, + {m68k_op_move_8_di_pcix , 0xf1ff, 0x117b, 22}, + {m68k_op_move_8_di_i , 0xf1ff, 0x117c, 16}, + {m68k_op_move_8_ix_pi7 , 0xf1ff, 0x119f, 18}, + {m68k_op_move_8_ix_pd7 , 0xf1ff, 0x11a7, 20}, + {m68k_op_move_8_ix_aw , 0xf1ff, 0x11b8, 22}, + {m68k_op_move_8_ix_al , 0xf1ff, 0x11b9, 26}, + {m68k_op_move_8_ix_pcdi , 0xf1ff, 0x11ba, 22}, + {m68k_op_move_8_ix_pcix , 0xf1ff, 0x11bb, 24}, + {m68k_op_move_8_ix_i , 0xf1ff, 0x11bc, 18}, + {m68k_op_move_32_d_aw , 0xf1ff, 0x2038, 16}, + {m68k_op_move_32_d_al , 0xf1ff, 0x2039, 20}, + {m68k_op_move_32_d_pcdi , 0xf1ff, 0x203a, 16}, + {m68k_op_move_32_d_pcix , 0xf1ff, 0x203b, 18}, + {m68k_op_move_32_d_i , 0xf1ff, 0x203c, 12}, + {m68k_op_movea_32_aw , 0xf1ff, 0x2078, 16}, + {m68k_op_movea_32_al , 0xf1ff, 0x2079, 20}, + {m68k_op_movea_32_pcdi , 0xf1ff, 0x207a, 16}, + {m68k_op_movea_32_pcix , 0xf1ff, 0x207b, 18}, + {m68k_op_movea_32_i , 0xf1ff, 0x207c, 12}, + {m68k_op_move_32_ai_aw , 0xf1ff, 0x20b8, 24}, + {m68k_op_move_32_ai_al , 0xf1ff, 0x20b9, 28}, + {m68k_op_move_32_ai_pcdi , 0xf1ff, 0x20ba, 24}, + {m68k_op_move_32_ai_pcix , 0xf1ff, 0x20bb, 26}, + {m68k_op_move_32_ai_i , 0xf1ff, 0x20bc, 20}, + {m68k_op_move_32_pi_aw , 0xf1ff, 0x20f8, 24}, + {m68k_op_move_32_pi_al , 0xf1ff, 0x20f9, 28}, + {m68k_op_move_32_pi_pcdi , 0xf1ff, 0x20fa, 24}, + {m68k_op_move_32_pi_pcix , 0xf1ff, 0x20fb, 26}, + {m68k_op_move_32_pi_i , 0xf1ff, 0x20fc, 20}, + {m68k_op_move_32_pd_aw , 0xf1ff, 0x2138, 24}, + {m68k_op_move_32_pd_al , 0xf1ff, 0x2139, 28}, + {m68k_op_move_32_pd_pcdi , 0xf1ff, 0x213a, 24}, + {m68k_op_move_32_pd_pcix , 0xf1ff, 0x213b, 26}, + {m68k_op_move_32_pd_i , 0xf1ff, 0x213c, 20}, + {m68k_op_move_32_di_aw , 0xf1ff, 0x2178, 28}, + {m68k_op_move_32_di_al , 0xf1ff, 0x2179, 32}, + {m68k_op_move_32_di_pcdi , 0xf1ff, 0x217a, 28}, + {m68k_op_move_32_di_pcix , 0xf1ff, 0x217b, 30}, + {m68k_op_move_32_di_i , 0xf1ff, 0x217c, 24}, + {m68k_op_move_32_ix_aw , 0xf1ff, 0x21b8, 30}, + {m68k_op_move_32_ix_al , 0xf1ff, 0x21b9, 34}, + {m68k_op_move_32_ix_pcdi , 0xf1ff, 0x21ba, 30}, + {m68k_op_move_32_ix_pcix , 0xf1ff, 0x21bb, 32}, + {m68k_op_move_32_ix_i , 0xf1ff, 0x21bc, 26}, + {m68k_op_move_16_d_aw , 0xf1ff, 0x3038, 12}, + {m68k_op_move_16_d_al , 0xf1ff, 0x3039, 16}, + {m68k_op_move_16_d_pcdi , 0xf1ff, 0x303a, 12}, + {m68k_op_move_16_d_pcix , 0xf1ff, 0x303b, 14}, + {m68k_op_move_16_d_i , 0xf1ff, 0x303c, 8}, + {m68k_op_movea_16_aw , 0xf1ff, 0x3078, 12}, + {m68k_op_movea_16_al , 0xf1ff, 0x3079, 16}, + {m68k_op_movea_16_pcdi , 0xf1ff, 0x307a, 12}, + {m68k_op_movea_16_pcix , 0xf1ff, 0x307b, 14}, + {m68k_op_movea_16_i , 0xf1ff, 0x307c, 8}, + {m68k_op_move_16_ai_aw , 0xf1ff, 0x30b8, 16}, + {m68k_op_move_16_ai_al , 0xf1ff, 0x30b9, 20}, + {m68k_op_move_16_ai_pcdi , 0xf1ff, 0x30ba, 16}, + {m68k_op_move_16_ai_pcix , 0xf1ff, 0x30bb, 18}, + {m68k_op_move_16_ai_i , 0xf1ff, 0x30bc, 12}, + {m68k_op_move_16_pi_aw , 0xf1ff, 0x30f8, 16}, + {m68k_op_move_16_pi_al , 0xf1ff, 0x30f9, 20}, + {m68k_op_move_16_pi_pcdi , 0xf1ff, 0x30fa, 16}, + {m68k_op_move_16_pi_pcix , 0xf1ff, 0x30fb, 18}, + {m68k_op_move_16_pi_i , 0xf1ff, 0x30fc, 12}, + {m68k_op_move_16_pd_aw , 0xf1ff, 0x3138, 16}, + {m68k_op_move_16_pd_al , 0xf1ff, 0x3139, 20}, + {m68k_op_move_16_pd_pcdi , 0xf1ff, 0x313a, 16}, + {m68k_op_move_16_pd_pcix , 0xf1ff, 0x313b, 18}, + {m68k_op_move_16_pd_i , 0xf1ff, 0x313c, 12}, + {m68k_op_move_16_di_aw , 0xf1ff, 0x3178, 20}, + {m68k_op_move_16_di_al , 0xf1ff, 0x3179, 24}, + {m68k_op_move_16_di_pcdi , 0xf1ff, 0x317a, 20}, + {m68k_op_move_16_di_pcix , 0xf1ff, 0x317b, 22}, + {m68k_op_move_16_di_i , 0xf1ff, 0x317c, 16}, + {m68k_op_move_16_ix_aw , 0xf1ff, 0x31b8, 22}, + {m68k_op_move_16_ix_al , 0xf1ff, 0x31b9, 26}, + {m68k_op_move_16_ix_pcdi , 0xf1ff, 0x31ba, 22}, + {m68k_op_move_16_ix_pcix , 0xf1ff, 0x31bb, 24}, + {m68k_op_move_16_ix_i , 0xf1ff, 0x31bc, 18}, + {m68k_op_chk_16_aw , 0xf1ff, 0x41b8, 18}, + {m68k_op_chk_16_al , 0xf1ff, 0x41b9, 22}, + {m68k_op_chk_16_pcdi , 0xf1ff, 0x41ba, 18}, + {m68k_op_chk_16_pcix , 0xf1ff, 0x41bb, 20}, + {m68k_op_chk_16_i , 0xf1ff, 0x41bc, 14}, + {m68k_op_lea_32_aw , 0xf1ff, 0x41f8, 8}, + {m68k_op_lea_32_al , 0xf1ff, 0x41f9, 12}, + {m68k_op_lea_32_pcdi , 0xf1ff, 0x41fa, 8}, + {m68k_op_lea_32_pcix , 0xf1ff, 0x41fb, 12}, + {m68k_op_addq_8_pi7 , 0xf1ff, 0x501f, 12}, + {m68k_op_addq_8_pd7 , 0xf1ff, 0x5027, 14}, + {m68k_op_addq_8_aw , 0xf1ff, 0x5038, 16}, + {m68k_op_addq_8_al , 0xf1ff, 0x5039, 20}, + {m68k_op_addq_16_aw , 0xf1ff, 0x5078, 16}, + {m68k_op_addq_16_al , 0xf1ff, 0x5079, 20}, + {m68k_op_addq_32_aw , 0xf1ff, 0x50b8, 24}, + {m68k_op_addq_32_al , 0xf1ff, 0x50b9, 28}, + {m68k_op_subq_8_pi7 , 0xf1ff, 0x511f, 12}, + {m68k_op_subq_8_pd7 , 0xf1ff, 0x5127, 14}, + {m68k_op_subq_8_aw , 0xf1ff, 0x5138, 16}, + {m68k_op_subq_8_al , 0xf1ff, 0x5139, 20}, + {m68k_op_subq_16_aw , 0xf1ff, 0x5178, 16}, + {m68k_op_subq_16_al , 0xf1ff, 0x5179, 20}, + {m68k_op_subq_32_aw , 0xf1ff, 0x51b8, 24}, + {m68k_op_subq_32_al , 0xf1ff, 0x51b9, 28}, + {m68k_op_or_8_er_pi7 , 0xf1ff, 0x801f, 8}, + {m68k_op_or_8_er_pd7 , 0xf1ff, 0x8027, 10}, + {m68k_op_or_8_er_aw , 0xf1ff, 0x8038, 12}, + {m68k_op_or_8_er_al , 0xf1ff, 0x8039, 16}, + {m68k_op_or_8_er_pcdi , 0xf1ff, 0x803a, 12}, + {m68k_op_or_8_er_pcix , 0xf1ff, 0x803b, 14}, + {m68k_op_or_8_er_i , 0xf1ff, 0x803c, 8}, + {m68k_op_or_16_er_aw , 0xf1ff, 0x8078, 12}, + {m68k_op_or_16_er_al , 0xf1ff, 0x8079, 16}, + {m68k_op_or_16_er_pcdi , 0xf1ff, 0x807a, 12}, + {m68k_op_or_16_er_pcix , 0xf1ff, 0x807b, 14}, + {m68k_op_or_16_er_i , 0xf1ff, 0x807c, 8}, + {m68k_op_or_32_er_aw , 0xf1ff, 0x80b8, 18}, + {m68k_op_or_32_er_al , 0xf1ff, 0x80b9, 22}, + {m68k_op_or_32_er_pcdi , 0xf1ff, 0x80ba, 18}, + {m68k_op_or_32_er_pcix , 0xf1ff, 0x80bb, 20}, + {m68k_op_or_32_er_i , 0xf1ff, 0x80bc, 16}, + {m68k_op_divu_16_aw , 0xf1ff, 0x80f8, 8}, + {m68k_op_divu_16_al , 0xf1ff, 0x80f9, 12}, + {m68k_op_divu_16_pcdi , 0xf1ff, 0x80fa, 8}, + {m68k_op_divu_16_pcix , 0xf1ff, 0x80fb, 10}, + {m68k_op_divu_16_i , 0xf1ff, 0x80fc, 4}, + {m68k_op_sbcd_8_mm_ay7 , 0xf1ff, 0x810f, 18}, + {m68k_op_or_8_re_pi7 , 0xf1ff, 0x811f, 12}, + {m68k_op_or_8_re_pd7 , 0xf1ff, 0x8127, 14}, + {m68k_op_or_8_re_aw , 0xf1ff, 0x8138, 16}, + {m68k_op_or_8_re_al , 0xf1ff, 0x8139, 20}, + {m68k_op_or_16_re_aw , 0xf1ff, 0x8178, 16}, + {m68k_op_or_16_re_al , 0xf1ff, 0x8179, 20}, + {m68k_op_or_32_re_aw , 0xf1ff, 0x81b8, 24}, + {m68k_op_or_32_re_al , 0xf1ff, 0x81b9, 28}, + {m68k_op_divs_16_aw , 0xf1ff, 0x81f8, 8}, + {m68k_op_divs_16_al , 0xf1ff, 0x81f9, 12}, + {m68k_op_divs_16_pcdi , 0xf1ff, 0x81fa, 8}, + {m68k_op_divs_16_pcix , 0xf1ff, 0x81fb, 10}, + {m68k_op_divs_16_i , 0xf1ff, 0x81fc, 4}, + {m68k_op_sub_8_er_pi7 , 0xf1ff, 0x901f, 8}, + {m68k_op_sub_8_er_pd7 , 0xf1ff, 0x9027, 10}, + {m68k_op_sub_8_er_aw , 0xf1ff, 0x9038, 12}, + {m68k_op_sub_8_er_al , 0xf1ff, 0x9039, 16}, + {m68k_op_sub_8_er_pcdi , 0xf1ff, 0x903a, 12}, + {m68k_op_sub_8_er_pcix , 0xf1ff, 0x903b, 14}, + {m68k_op_sub_8_er_i , 0xf1ff, 0x903c, 8}, + {m68k_op_sub_16_er_aw , 0xf1ff, 0x9078, 12}, + {m68k_op_sub_16_er_al , 0xf1ff, 0x9079, 16}, + {m68k_op_sub_16_er_pcdi , 0xf1ff, 0x907a, 12}, + {m68k_op_sub_16_er_pcix , 0xf1ff, 0x907b, 14}, + {m68k_op_sub_16_er_i , 0xf1ff, 0x907c, 8}, + {m68k_op_sub_32_er_aw , 0xf1ff, 0x90b8, 18}, + {m68k_op_sub_32_er_al , 0xf1ff, 0x90b9, 22}, + {m68k_op_sub_32_er_pcdi , 0xf1ff, 0x90ba, 18}, + {m68k_op_sub_32_er_pcix , 0xf1ff, 0x90bb, 20}, + {m68k_op_sub_32_er_i , 0xf1ff, 0x90bc, 16}, + {m68k_op_suba_16_aw , 0xf1ff, 0x90f8, 16}, + {m68k_op_suba_16_al , 0xf1ff, 0x90f9, 20}, + {m68k_op_suba_16_pcdi , 0xf1ff, 0x90fa, 16}, + {m68k_op_suba_16_pcix , 0xf1ff, 0x90fb, 18}, + {m68k_op_suba_16_i , 0xf1ff, 0x90fc, 12}, + {m68k_op_subx_8_mm_ay7 , 0xf1ff, 0x910f, 18}, + {m68k_op_sub_8_re_pi7 , 0xf1ff, 0x911f, 12}, + {m68k_op_sub_8_re_pd7 , 0xf1ff, 0x9127, 14}, + {m68k_op_sub_8_re_aw , 0xf1ff, 0x9138, 16}, + {m68k_op_sub_8_re_al , 0xf1ff, 0x9139, 20}, + {m68k_op_sub_16_re_aw , 0xf1ff, 0x9178, 16}, + {m68k_op_sub_16_re_al , 0xf1ff, 0x9179, 20}, + {m68k_op_sub_32_re_aw , 0xf1ff, 0x91b8, 24}, + {m68k_op_sub_32_re_al , 0xf1ff, 0x91b9, 28}, + {m68k_op_suba_32_aw , 0xf1ff, 0x91f8, 18}, + {m68k_op_suba_32_al , 0xf1ff, 0x91f9, 22}, + {m68k_op_suba_32_pcdi , 0xf1ff, 0x91fa, 18}, + {m68k_op_suba_32_pcix , 0xf1ff, 0x91fb, 20}, + {m68k_op_suba_32_i , 0xf1ff, 0x91fc, 16}, + {m68k_op_cmp_8_pi7 , 0xf1ff, 0xb01f, 8}, + {m68k_op_cmp_8_pd7 , 0xf1ff, 0xb027, 10}, + {m68k_op_cmp_8_aw , 0xf1ff, 0xb038, 12}, + {m68k_op_cmp_8_al , 0xf1ff, 0xb039, 16}, + {m68k_op_cmp_8_pcdi , 0xf1ff, 0xb03a, 12}, + {m68k_op_cmp_8_pcix , 0xf1ff, 0xb03b, 14}, + {m68k_op_cmp_8_i , 0xf1ff, 0xb03c, 8}, + {m68k_op_cmp_16_aw , 0xf1ff, 0xb078, 12}, + {m68k_op_cmp_16_al , 0xf1ff, 0xb079, 16}, + {m68k_op_cmp_16_pcdi , 0xf1ff, 0xb07a, 12}, + {m68k_op_cmp_16_pcix , 0xf1ff, 0xb07b, 14}, + {m68k_op_cmp_16_i , 0xf1ff, 0xb07c, 8}, + {m68k_op_cmp_32_aw , 0xf1ff, 0xb0b8, 18}, + {m68k_op_cmp_32_al , 0xf1ff, 0xb0b9, 22}, + {m68k_op_cmp_32_pcdi , 0xf1ff, 0xb0ba, 18}, + {m68k_op_cmp_32_pcix , 0xf1ff, 0xb0bb, 20}, + {m68k_op_cmp_32_i , 0xf1ff, 0xb0bc, 14}, + {m68k_op_cmpa_16_aw , 0xf1ff, 0xb0f8, 14}, + {m68k_op_cmpa_16_al , 0xf1ff, 0xb0f9, 18}, + {m68k_op_cmpa_16_pcdi , 0xf1ff, 0xb0fa, 14}, + {m68k_op_cmpa_16_pcix , 0xf1ff, 0xb0fb, 16}, + {m68k_op_cmpa_16_i , 0xf1ff, 0xb0fc, 10}, + {m68k_op_cmpm_8_ay7 , 0xf1ff, 0xb10f, 12}, + {m68k_op_eor_8_pi7 , 0xf1ff, 0xb11f, 12}, + {m68k_op_eor_8_pd7 , 0xf1ff, 0xb127, 14}, + {m68k_op_eor_8_aw , 0xf1ff, 0xb138, 16}, + {m68k_op_eor_8_al , 0xf1ff, 0xb139, 20}, + {m68k_op_eor_16_aw , 0xf1ff, 0xb178, 16}, + {m68k_op_eor_16_al , 0xf1ff, 0xb179, 20}, + {m68k_op_eor_32_aw , 0xf1ff, 0xb1b8, 24}, + {m68k_op_eor_32_al , 0xf1ff, 0xb1b9, 28}, + {m68k_op_cmpa_32_aw , 0xf1ff, 0xb1f8, 18}, + {m68k_op_cmpa_32_al , 0xf1ff, 0xb1f9, 22}, + {m68k_op_cmpa_32_pcdi , 0xf1ff, 0xb1fa, 18}, + {m68k_op_cmpa_32_pcix , 0xf1ff, 0xb1fb, 20}, + {m68k_op_cmpa_32_i , 0xf1ff, 0xb1fc, 14}, + {m68k_op_and_8_er_pi7 , 0xf1ff, 0xc01f, 8}, + {m68k_op_and_8_er_pd7 , 0xf1ff, 0xc027, 10}, + {m68k_op_and_8_er_aw , 0xf1ff, 0xc038, 12}, + {m68k_op_and_8_er_al , 0xf1ff, 0xc039, 16}, + {m68k_op_and_8_er_pcdi , 0xf1ff, 0xc03a, 12}, + {m68k_op_and_8_er_pcix , 0xf1ff, 0xc03b, 14}, + {m68k_op_and_8_er_i , 0xf1ff, 0xc03c, 8}, + {m68k_op_and_16_er_aw , 0xf1ff, 0xc078, 12}, + {m68k_op_and_16_er_al , 0xf1ff, 0xc079, 16}, + {m68k_op_and_16_er_pcdi , 0xf1ff, 0xc07a, 12}, + {m68k_op_and_16_er_pcix , 0xf1ff, 0xc07b, 14}, + {m68k_op_and_16_er_i , 0xf1ff, 0xc07c, 8}, + {m68k_op_and_32_er_aw , 0xf1ff, 0xc0b8, 18}, + {m68k_op_and_32_er_al , 0xf1ff, 0xc0b9, 22}, + {m68k_op_and_32_er_pcdi , 0xf1ff, 0xc0ba, 18}, + {m68k_op_and_32_er_pcix , 0xf1ff, 0xc0bb, 20}, + {m68k_op_and_32_er_i , 0xf1ff, 0xc0bc, 16}, + {m68k_op_mulu_16_aw , 0xf1ff, 0xc0f8, 8}, + {m68k_op_mulu_16_al , 0xf1ff, 0xc0f9, 12}, + {m68k_op_mulu_16_pcdi , 0xf1ff, 0xc0fa, 8}, + {m68k_op_mulu_16_pcix , 0xf1ff, 0xc0fb, 10}, + {m68k_op_mulu_16_i , 0xf1ff, 0xc0fc, 4}, + {m68k_op_abcd_8_mm_ay7 , 0xf1ff, 0xc10f, 18}, + {m68k_op_and_8_re_pi7 , 0xf1ff, 0xc11f, 12}, + {m68k_op_and_8_re_pd7 , 0xf1ff, 0xc127, 14}, + {m68k_op_and_8_re_aw , 0xf1ff, 0xc138, 16}, + {m68k_op_and_8_re_al , 0xf1ff, 0xc139, 20}, + {m68k_op_and_16_re_aw , 0xf1ff, 0xc178, 16}, + {m68k_op_and_16_re_al , 0xf1ff, 0xc179, 20}, + {m68k_op_and_32_re_aw , 0xf1ff, 0xc1b8, 24}, + {m68k_op_and_32_re_al , 0xf1ff, 0xc1b9, 28}, + {m68k_op_muls_16_aw , 0xf1ff, 0xc1f8, 8}, + {m68k_op_muls_16_al , 0xf1ff, 0xc1f9, 12}, + {m68k_op_muls_16_pcdi , 0xf1ff, 0xc1fa, 8}, + {m68k_op_muls_16_pcix , 0xf1ff, 0xc1fb, 10}, + {m68k_op_muls_16_i , 0xf1ff, 0xc1fc, 4}, + {m68k_op_add_8_er_pi7 , 0xf1ff, 0xd01f, 8}, + {m68k_op_add_8_er_pd7 , 0xf1ff, 0xd027, 10}, + {m68k_op_add_8_er_aw , 0xf1ff, 0xd038, 12}, + {m68k_op_add_8_er_al , 0xf1ff, 0xd039, 16}, + {m68k_op_add_8_er_pcdi , 0xf1ff, 0xd03a, 12}, + {m68k_op_add_8_er_pcix , 0xf1ff, 0xd03b, 14}, + {m68k_op_add_8_er_i , 0xf1ff, 0xd03c, 8}, + {m68k_op_add_16_er_aw , 0xf1ff, 0xd078, 12}, + {m68k_op_add_16_er_al , 0xf1ff, 0xd079, 16}, + {m68k_op_add_16_er_pcdi , 0xf1ff, 0xd07a, 12}, + {m68k_op_add_16_er_pcix , 0xf1ff, 0xd07b, 14}, + {m68k_op_add_16_er_i , 0xf1ff, 0xd07c, 8}, + {m68k_op_add_32_er_aw , 0xf1ff, 0xd0b8, 18}, + {m68k_op_add_32_er_al , 0xf1ff, 0xd0b9, 22}, + {m68k_op_add_32_er_pcdi , 0xf1ff, 0xd0ba, 18}, + {m68k_op_add_32_er_pcix , 0xf1ff, 0xd0bb, 20}, + {m68k_op_add_32_er_i , 0xf1ff, 0xd0bc, 16}, + {m68k_op_adda_16_aw , 0xf1ff, 0xd0f8, 16}, + {m68k_op_adda_16_al , 0xf1ff, 0xd0f9, 20}, + {m68k_op_adda_16_pcdi , 0xf1ff, 0xd0fa, 16}, + {m68k_op_adda_16_pcix , 0xf1ff, 0xd0fb, 18}, + {m68k_op_adda_16_i , 0xf1ff, 0xd0fc, 12}, + {m68k_op_addx_8_mm_ay7 , 0xf1ff, 0xd10f, 18}, + {m68k_op_add_8_re_pi7 , 0xf1ff, 0xd11f, 12}, + {m68k_op_add_8_re_pd7 , 0xf1ff, 0xd127, 14}, + {m68k_op_add_8_re_aw , 0xf1ff, 0xd138, 16}, + {m68k_op_add_8_re_al , 0xf1ff, 0xd139, 20}, + {m68k_op_add_16_re_aw , 0xf1ff, 0xd178, 16}, + {m68k_op_add_16_re_al , 0xf1ff, 0xd179, 20}, + {m68k_op_add_32_re_aw , 0xf1ff, 0xd1b8, 24}, + {m68k_op_add_32_re_al , 0xf1ff, 0xd1b9, 28}, + {m68k_op_adda_32_aw , 0xf1ff, 0xd1f8, 18}, + {m68k_op_adda_32_al , 0xf1ff, 0xd1f9, 22}, + {m68k_op_adda_32_pcdi , 0xf1ff, 0xd1fa, 18}, + {m68k_op_adda_32_pcix , 0xf1ff, 0xd1fb, 20}, + {m68k_op_adda_32_i , 0xf1ff, 0xd1fc, 16}, + {m68k_op_ori_8_d , 0xfff8, 0x0000, 8}, + {m68k_op_ori_8_ai , 0xfff8, 0x0010, 16}, + {m68k_op_ori_8_pi , 0xfff8, 0x0018, 16}, + {m68k_op_ori_8_pd , 0xfff8, 0x0020, 18}, + {m68k_op_ori_8_di , 0xfff8, 0x0028, 20}, + {m68k_op_ori_8_ix , 0xfff8, 0x0030, 22}, + {m68k_op_ori_16_d , 0xfff8, 0x0040, 8}, + {m68k_op_ori_16_ai , 0xfff8, 0x0050, 16}, + {m68k_op_ori_16_pi , 0xfff8, 0x0058, 16}, + {m68k_op_ori_16_pd , 0xfff8, 0x0060, 18}, + {m68k_op_ori_16_di , 0xfff8, 0x0068, 20}, + {m68k_op_ori_16_ix , 0xfff8, 0x0070, 22}, + {m68k_op_ori_32_d , 0xfff8, 0x0080, 16}, + {m68k_op_ori_32_ai , 0xfff8, 0x0090, 28}, + {m68k_op_ori_32_pi , 0xfff8, 0x0098, 28}, + {m68k_op_ori_32_pd , 0xfff8, 0x00a0, 30}, + {m68k_op_ori_32_di , 0xfff8, 0x00a8, 32}, + {m68k_op_ori_32_ix , 0xfff8, 0x00b0, 34}, + {m68k_op_andi_8_d , 0xfff8, 0x0200, 8}, + {m68k_op_andi_8_ai , 0xfff8, 0x0210, 16}, + {m68k_op_andi_8_pi , 0xfff8, 0x0218, 16}, + {m68k_op_andi_8_pd , 0xfff8, 0x0220, 18}, + {m68k_op_andi_8_di , 0xfff8, 0x0228, 20}, + {m68k_op_andi_8_ix , 0xfff8, 0x0230, 22}, + {m68k_op_andi_16_d , 0xfff8, 0x0240, 8}, + {m68k_op_andi_16_ai , 0xfff8, 0x0250, 16}, + {m68k_op_andi_16_pi , 0xfff8, 0x0258, 16}, + {m68k_op_andi_16_pd , 0xfff8, 0x0260, 18}, + {m68k_op_andi_16_di , 0xfff8, 0x0268, 20}, + {m68k_op_andi_16_ix , 0xfff8, 0x0270, 22}, + {m68k_op_andi_32_d , 0xfff8, 0x0280, 14}, + {m68k_op_andi_32_ai , 0xfff8, 0x0290, 28}, + {m68k_op_andi_32_pi , 0xfff8, 0x0298, 28}, + {m68k_op_andi_32_pd , 0xfff8, 0x02a0, 30}, + {m68k_op_andi_32_di , 0xfff8, 0x02a8, 32}, + {m68k_op_andi_32_ix , 0xfff8, 0x02b0, 34}, + {m68k_op_subi_8_d , 0xfff8, 0x0400, 8}, + {m68k_op_subi_8_ai , 0xfff8, 0x0410, 16}, + {m68k_op_subi_8_pi , 0xfff8, 0x0418, 16}, + {m68k_op_subi_8_pd , 0xfff8, 0x0420, 18}, + {m68k_op_subi_8_di , 0xfff8, 0x0428, 20}, + {m68k_op_subi_8_ix , 0xfff8, 0x0430, 22}, + {m68k_op_subi_16_d , 0xfff8, 0x0440, 8}, + {m68k_op_subi_16_ai , 0xfff8, 0x0450, 16}, + {m68k_op_subi_16_pi , 0xfff8, 0x0458, 16}, + {m68k_op_subi_16_pd , 0xfff8, 0x0460, 18}, + {m68k_op_subi_16_di , 0xfff8, 0x0468, 20}, + {m68k_op_subi_16_ix , 0xfff8, 0x0470, 22}, + {m68k_op_subi_32_d , 0xfff8, 0x0480, 16}, + {m68k_op_subi_32_ai , 0xfff8, 0x0490, 28}, + {m68k_op_subi_32_pi , 0xfff8, 0x0498, 28}, + {m68k_op_subi_32_pd , 0xfff8, 0x04a0, 30}, + {m68k_op_subi_32_di , 0xfff8, 0x04a8, 32}, + {m68k_op_subi_32_ix , 0xfff8, 0x04b0, 34}, + {m68k_op_addi_8_d , 0xfff8, 0x0600, 8}, + {m68k_op_addi_8_ai , 0xfff8, 0x0610, 16}, + {m68k_op_addi_8_pi , 0xfff8, 0x0618, 16}, + {m68k_op_addi_8_pd , 0xfff8, 0x0620, 18}, + {m68k_op_addi_8_di , 0xfff8, 0x0628, 20}, + {m68k_op_addi_8_ix , 0xfff8, 0x0630, 22}, + {m68k_op_addi_16_d , 0xfff8, 0x0640, 8}, + {m68k_op_addi_16_ai , 0xfff8, 0x0650, 16}, + {m68k_op_addi_16_pi , 0xfff8, 0x0658, 16}, + {m68k_op_addi_16_pd , 0xfff8, 0x0660, 18}, + {m68k_op_addi_16_di , 0xfff8, 0x0668, 20}, + {m68k_op_addi_16_ix , 0xfff8, 0x0670, 22}, + {m68k_op_addi_32_d , 0xfff8, 0x0680, 16}, + {m68k_op_addi_32_ai , 0xfff8, 0x0690, 28}, + {m68k_op_addi_32_pi , 0xfff8, 0x0698, 28}, + {m68k_op_addi_32_pd , 0xfff8, 0x06a0, 30}, + {m68k_op_addi_32_di , 0xfff8, 0x06a8, 32}, + {m68k_op_addi_32_ix , 0xfff8, 0x06b0, 34}, + {m68k_op_btst_32_s_d , 0xfff8, 0x0800, 10}, + {m68k_op_btst_8_s_ai , 0xfff8, 0x0810, 12}, + {m68k_op_btst_8_s_pi , 0xfff8, 0x0818, 12}, + {m68k_op_btst_8_s_pd , 0xfff8, 0x0820, 14}, + {m68k_op_btst_8_s_di , 0xfff8, 0x0828, 16}, + {m68k_op_btst_8_s_ix , 0xfff8, 0x0830, 18}, + {m68k_op_bchg_32_s_d , 0xfff8, 0x0840, 12}, + {m68k_op_bchg_8_s_ai , 0xfff8, 0x0850, 16}, + {m68k_op_bchg_8_s_pi , 0xfff8, 0x0858, 16}, + {m68k_op_bchg_8_s_pd , 0xfff8, 0x0860, 18}, + {m68k_op_bchg_8_s_di , 0xfff8, 0x0868, 20}, + {m68k_op_bchg_8_s_ix , 0xfff8, 0x0870, 22}, + {m68k_op_bclr_32_s_d , 0xfff8, 0x0880, 14}, + {m68k_op_bclr_8_s_ai , 0xfff8, 0x0890, 16}, + {m68k_op_bclr_8_s_pi , 0xfff8, 0x0898, 16}, + {m68k_op_bclr_8_s_pd , 0xfff8, 0x08a0, 18}, + {m68k_op_bclr_8_s_di , 0xfff8, 0x08a8, 20}, + {m68k_op_bclr_8_s_ix , 0xfff8, 0x08b0, 22}, + {m68k_op_bset_32_s_d , 0xfff8, 0x08c0, 12}, + {m68k_op_bset_8_s_ai , 0xfff8, 0x08d0, 16}, + {m68k_op_bset_8_s_pi , 0xfff8, 0x08d8, 16}, + {m68k_op_bset_8_s_pd , 0xfff8, 0x08e0, 18}, + {m68k_op_bset_8_s_di , 0xfff8, 0x08e8, 20}, + {m68k_op_bset_8_s_ix , 0xfff8, 0x08f0, 22}, + {m68k_op_eori_8_d , 0xfff8, 0x0a00, 8}, + {m68k_op_eori_8_ai , 0xfff8, 0x0a10, 16}, + {m68k_op_eori_8_pi , 0xfff8, 0x0a18, 16}, + {m68k_op_eori_8_pd , 0xfff8, 0x0a20, 18}, + {m68k_op_eori_8_di , 0xfff8, 0x0a28, 20}, + {m68k_op_eori_8_ix , 0xfff8, 0x0a30, 22}, + {m68k_op_eori_16_d , 0xfff8, 0x0a40, 8}, + {m68k_op_eori_16_ai , 0xfff8, 0x0a50, 16}, + {m68k_op_eori_16_pi , 0xfff8, 0x0a58, 16}, + {m68k_op_eori_16_pd , 0xfff8, 0x0a60, 18}, + {m68k_op_eori_16_di , 0xfff8, 0x0a68, 20}, + {m68k_op_eori_16_ix , 0xfff8, 0x0a70, 22}, + {m68k_op_eori_32_d , 0xfff8, 0x0a80, 16}, + {m68k_op_eori_32_ai , 0xfff8, 0x0a90, 28}, + {m68k_op_eori_32_pi , 0xfff8, 0x0a98, 28}, + {m68k_op_eori_32_pd , 0xfff8, 0x0aa0, 30}, + {m68k_op_eori_32_di , 0xfff8, 0x0aa8, 32}, + {m68k_op_eori_32_ix , 0xfff8, 0x0ab0, 34}, + {m68k_op_cmpi_8_d , 0xfff8, 0x0c00, 8}, + {m68k_op_cmpi_8_ai , 0xfff8, 0x0c10, 12}, + {m68k_op_cmpi_8_pi , 0xfff8, 0x0c18, 12}, + {m68k_op_cmpi_8_pd , 0xfff8, 0x0c20, 14}, + {m68k_op_cmpi_8_di , 0xfff8, 0x0c28, 16}, + {m68k_op_cmpi_8_ix , 0xfff8, 0x0c30, 18}, + {m68k_op_cmpi_16_d , 0xfff8, 0x0c40, 8}, + {m68k_op_cmpi_16_ai , 0xfff8, 0x0c50, 12}, + {m68k_op_cmpi_16_pi , 0xfff8, 0x0c58, 12}, + {m68k_op_cmpi_16_pd , 0xfff8, 0x0c60, 14}, + {m68k_op_cmpi_16_di , 0xfff8, 0x0c68, 16}, + {m68k_op_cmpi_16_ix , 0xfff8, 0x0c70, 18}, + {m68k_op_cmpi_32_d , 0xfff8, 0x0c80, 14}, + {m68k_op_cmpi_32_ai , 0xfff8, 0x0c90, 20}, + {m68k_op_cmpi_32_pi , 0xfff8, 0x0c98, 20}, + {m68k_op_cmpi_32_pd , 0xfff8, 0x0ca0, 22}, + {m68k_op_cmpi_32_di , 0xfff8, 0x0ca8, 24}, + {m68k_op_cmpi_32_ix , 0xfff8, 0x0cb0, 26}, + {m68k_op_move_8_aw_d , 0xfff8, 0x11c0, 12}, + {m68k_op_move_8_aw_ai , 0xfff8, 0x11d0, 16}, + {m68k_op_move_8_aw_pi , 0xfff8, 0x11d8, 16}, + {m68k_op_move_8_aw_pd , 0xfff8, 0x11e0, 18}, + {m68k_op_move_8_aw_di , 0xfff8, 0x11e8, 20}, + {m68k_op_move_8_aw_ix , 0xfff8, 0x11f0, 22}, + {m68k_op_move_8_al_d , 0xfff8, 0x13c0, 16}, + {m68k_op_move_8_al_ai , 0xfff8, 0x13d0, 20}, + {m68k_op_move_8_al_pi , 0xfff8, 0x13d8, 20}, + {m68k_op_move_8_al_pd , 0xfff8, 0x13e0, 22}, + {m68k_op_move_8_al_di , 0xfff8, 0x13e8, 24}, + {m68k_op_move_8_al_ix , 0xfff8, 0x13f0, 26}, + {m68k_op_move_8_pi7_d , 0xfff8, 0x1ec0, 8}, + {m68k_op_move_8_pi7_ai , 0xfff8, 0x1ed0, 12}, + {m68k_op_move_8_pi7_pi , 0xfff8, 0x1ed8, 12}, + {m68k_op_move_8_pi7_pd , 0xfff8, 0x1ee0, 14}, + {m68k_op_move_8_pi7_di , 0xfff8, 0x1ee8, 16}, + {m68k_op_move_8_pi7_ix , 0xfff8, 0x1ef0, 18}, + {m68k_op_move_8_pd7_d , 0xfff8, 0x1f00, 8}, + {m68k_op_move_8_pd7_ai , 0xfff8, 0x1f10, 12}, + {m68k_op_move_8_pd7_pi , 0xfff8, 0x1f18, 12}, + {m68k_op_move_8_pd7_pd , 0xfff8, 0x1f20, 14}, + {m68k_op_move_8_pd7_di , 0xfff8, 0x1f28, 16}, + {m68k_op_move_8_pd7_ix , 0xfff8, 0x1f30, 18}, + {m68k_op_move_32_aw_d , 0xfff8, 0x21c0, 16}, + {m68k_op_move_32_aw_a , 0xfff8, 0x21c8, 16}, + {m68k_op_move_32_aw_ai , 0xfff8, 0x21d0, 24}, + {m68k_op_move_32_aw_pi , 0xfff8, 0x21d8, 24}, + {m68k_op_move_32_aw_pd , 0xfff8, 0x21e0, 26}, + {m68k_op_move_32_aw_di , 0xfff8, 0x21e8, 28}, + {m68k_op_move_32_aw_ix , 0xfff8, 0x21f0, 30}, + {m68k_op_move_32_al_d , 0xfff8, 0x23c0, 20}, + {m68k_op_move_32_al_a , 0xfff8, 0x23c8, 20}, + {m68k_op_move_32_al_ai , 0xfff8, 0x23d0, 28}, + {m68k_op_move_32_al_pi , 0xfff8, 0x23d8, 28}, + {m68k_op_move_32_al_pd , 0xfff8, 0x23e0, 30}, + {m68k_op_move_32_al_di , 0xfff8, 0x23e8, 32}, + {m68k_op_move_32_al_ix , 0xfff8, 0x23f0, 34}, + {m68k_op_move_16_aw_d , 0xfff8, 0x31c0, 12}, + {m68k_op_move_16_aw_a , 0xfff8, 0x31c8, 12}, + {m68k_op_move_16_aw_ai , 0xfff8, 0x31d0, 16}, + {m68k_op_move_16_aw_pi , 0xfff8, 0x31d8, 16}, + {m68k_op_move_16_aw_pd , 0xfff8, 0x31e0, 18}, + {m68k_op_move_16_aw_di , 0xfff8, 0x31e8, 20}, + {m68k_op_move_16_aw_ix , 0xfff8, 0x31f0, 22}, + {m68k_op_move_16_al_d , 0xfff8, 0x33c0, 16}, + {m68k_op_move_16_al_a , 0xfff8, 0x33c8, 16}, + {m68k_op_move_16_al_ai , 0xfff8, 0x33d0, 20}, + {m68k_op_move_16_al_pi , 0xfff8, 0x33d8, 20}, + {m68k_op_move_16_al_pd , 0xfff8, 0x33e0, 22}, + {m68k_op_move_16_al_di , 0xfff8, 0x33e8, 24}, + {m68k_op_move_16_al_ix , 0xfff8, 0x33f0, 26}, + {m68k_op_negx_8_d , 0xfff8, 0x4000, 4}, + {m68k_op_negx_8_ai , 0xfff8, 0x4010, 12}, + {m68k_op_negx_8_pi , 0xfff8, 0x4018, 12}, + {m68k_op_negx_8_pd , 0xfff8, 0x4020, 14}, + {m68k_op_negx_8_di , 0xfff8, 0x4028, 16}, + {m68k_op_negx_8_ix , 0xfff8, 0x4030, 18}, + {m68k_op_negx_16_d , 0xfff8, 0x4040, 4}, + {m68k_op_negx_16_ai , 0xfff8, 0x4050, 12}, + {m68k_op_negx_16_pi , 0xfff8, 0x4058, 12}, + {m68k_op_negx_16_pd , 0xfff8, 0x4060, 14}, + {m68k_op_negx_16_di , 0xfff8, 0x4068, 16}, + {m68k_op_negx_16_ix , 0xfff8, 0x4070, 18}, + {m68k_op_negx_32_d , 0xfff8, 0x4080, 6}, + {m68k_op_negx_32_ai , 0xfff8, 0x4090, 20}, + {m68k_op_negx_32_pi , 0xfff8, 0x4098, 20}, + {m68k_op_negx_32_pd , 0xfff8, 0x40a0, 22}, + {m68k_op_negx_32_di , 0xfff8, 0x40a8, 24}, + {m68k_op_negx_32_ix , 0xfff8, 0x40b0, 26}, + {m68k_op_move_16_frs_d , 0xfff8, 0x40c0, 6}, + {m68k_op_move_16_frs_ai , 0xfff8, 0x40d0, 12}, + {m68k_op_move_16_frs_pi , 0xfff8, 0x40d8, 12}, + {m68k_op_move_16_frs_pd , 0xfff8, 0x40e0, 14}, + {m68k_op_move_16_frs_di , 0xfff8, 0x40e8, 16}, + {m68k_op_move_16_frs_ix , 0xfff8, 0x40f0, 18}, + {m68k_op_clr_8_d , 0xfff8, 0x4200, 4}, + {m68k_op_clr_8_ai , 0xfff8, 0x4210, 12}, + {m68k_op_clr_8_pi , 0xfff8, 0x4218, 12}, + {m68k_op_clr_8_pd , 0xfff8, 0x4220, 14}, + {m68k_op_clr_8_di , 0xfff8, 0x4228, 16}, + {m68k_op_clr_8_ix , 0xfff8, 0x4230, 18}, + {m68k_op_clr_16_d , 0xfff8, 0x4240, 4}, + {m68k_op_clr_16_ai , 0xfff8, 0x4250, 12}, + {m68k_op_clr_16_pi , 0xfff8, 0x4258, 12}, + {m68k_op_clr_16_pd , 0xfff8, 0x4260, 14}, + {m68k_op_clr_16_di , 0xfff8, 0x4268, 16}, + {m68k_op_clr_16_ix , 0xfff8, 0x4270, 18}, + {m68k_op_clr_32_d , 0xfff8, 0x4280, 6}, + {m68k_op_clr_32_ai , 0xfff8, 0x4290, 20}, + {m68k_op_clr_32_pi , 0xfff8, 0x4298, 20}, + {m68k_op_clr_32_pd , 0xfff8, 0x42a0, 22}, + {m68k_op_clr_32_di , 0xfff8, 0x42a8, 24}, + {m68k_op_clr_32_ix , 0xfff8, 0x42b0, 26}, + {m68k_op_neg_8_d , 0xfff8, 0x4400, 4}, + {m68k_op_neg_8_ai , 0xfff8, 0x4410, 12}, + {m68k_op_neg_8_pi , 0xfff8, 0x4418, 12}, + {m68k_op_neg_8_pd , 0xfff8, 0x4420, 14}, + {m68k_op_neg_8_di , 0xfff8, 0x4428, 16}, + {m68k_op_neg_8_ix , 0xfff8, 0x4430, 18}, + {m68k_op_neg_16_d , 0xfff8, 0x4440, 4}, + {m68k_op_neg_16_ai , 0xfff8, 0x4450, 12}, + {m68k_op_neg_16_pi , 0xfff8, 0x4458, 12}, + {m68k_op_neg_16_pd , 0xfff8, 0x4460, 14}, + {m68k_op_neg_16_di , 0xfff8, 0x4468, 16}, + {m68k_op_neg_16_ix , 0xfff8, 0x4470, 18}, + {m68k_op_neg_32_d , 0xfff8, 0x4480, 6}, + {m68k_op_neg_32_ai , 0xfff8, 0x4490, 20}, + {m68k_op_neg_32_pi , 0xfff8, 0x4498, 20}, + {m68k_op_neg_32_pd , 0xfff8, 0x44a0, 22}, + {m68k_op_neg_32_di , 0xfff8, 0x44a8, 24}, + {m68k_op_neg_32_ix , 0xfff8, 0x44b0, 26}, + {m68k_op_move_16_toc_d , 0xfff8, 0x44c0, 12}, + {m68k_op_move_16_toc_ai , 0xfff8, 0x44d0, 16}, + {m68k_op_move_16_toc_pi , 0xfff8, 0x44d8, 16}, + {m68k_op_move_16_toc_pd , 0xfff8, 0x44e0, 18}, + {m68k_op_move_16_toc_di , 0xfff8, 0x44e8, 20}, + {m68k_op_move_16_toc_ix , 0xfff8, 0x44f0, 22}, + {m68k_op_not_8_d , 0xfff8, 0x4600, 4}, + {m68k_op_not_8_ai , 0xfff8, 0x4610, 12}, + {m68k_op_not_8_pi , 0xfff8, 0x4618, 12}, + {m68k_op_not_8_pd , 0xfff8, 0x4620, 14}, + {m68k_op_not_8_di , 0xfff8, 0x4628, 16}, + {m68k_op_not_8_ix , 0xfff8, 0x4630, 18}, + {m68k_op_not_16_d , 0xfff8, 0x4640, 4}, + {m68k_op_not_16_ai , 0xfff8, 0x4650, 12}, + {m68k_op_not_16_pi , 0xfff8, 0x4658, 12}, + {m68k_op_not_16_pd , 0xfff8, 0x4660, 14}, + {m68k_op_not_16_di , 0xfff8, 0x4668, 16}, + {m68k_op_not_16_ix , 0xfff8, 0x4670, 18}, + {m68k_op_not_32_d , 0xfff8, 0x4680, 6}, + {m68k_op_not_32_ai , 0xfff8, 0x4690, 20}, + {m68k_op_not_32_pi , 0xfff8, 0x4698, 20}, + {m68k_op_not_32_pd , 0xfff8, 0x46a0, 22}, + {m68k_op_not_32_di , 0xfff8, 0x46a8, 24}, + {m68k_op_not_32_ix , 0xfff8, 0x46b0, 26}, + {m68k_op_move_16_tos_d , 0xfff8, 0x46c0, 12}, + {m68k_op_move_16_tos_ai , 0xfff8, 0x46d0, 16}, + {m68k_op_move_16_tos_pi , 0xfff8, 0x46d8, 16}, + {m68k_op_move_16_tos_pd , 0xfff8, 0x46e0, 18}, + {m68k_op_move_16_tos_di , 0xfff8, 0x46e8, 20}, + {m68k_op_move_16_tos_ix , 0xfff8, 0x46f0, 22}, + {m68k_op_nbcd_8_d , 0xfff8, 0x4800, 6}, + {m68k_op_nbcd_8_ai , 0xfff8, 0x4810, 12}, + {m68k_op_nbcd_8_pi , 0xfff8, 0x4818, 12}, + {m68k_op_nbcd_8_pd , 0xfff8, 0x4820, 14}, + {m68k_op_nbcd_8_di , 0xfff8, 0x4828, 16}, + {m68k_op_nbcd_8_ix , 0xfff8, 0x4830, 18}, + {m68k_op_swap_32 , 0xfff8, 0x4840, 4}, + {m68k_op_pea_32_ai , 0xfff8, 0x4850, 12}, + {m68k_op_pea_32_di , 0xfff8, 0x4868, 16}, + {m68k_op_pea_32_ix , 0xfff8, 0x4870, 20}, + {m68k_op_ext_16 , 0xfff8, 0x4880, 4}, + {m68k_op_movem_16_re_ai , 0xfff8, 0x4890, 8}, + {m68k_op_movem_16_re_pd , 0xfff8, 0x48a0, 8}, + {m68k_op_movem_16_re_di , 0xfff8, 0x48a8, 12}, + {m68k_op_movem_16_re_ix , 0xfff8, 0x48b0, 14}, + {m68k_op_ext_32 , 0xfff8, 0x48c0, 4}, + {m68k_op_movem_32_re_ai , 0xfff8, 0x48d0, 8}, + {m68k_op_movem_32_re_pd , 0xfff8, 0x48e0, 8}, + {m68k_op_movem_32_re_di , 0xfff8, 0x48e8, 12}, + {m68k_op_movem_32_re_ix , 0xfff8, 0x48f0, 14}, + {m68k_op_tst_8_d , 0xfff8, 0x4a00, 4}, + {m68k_op_tst_8_ai , 0xfff8, 0x4a10, 8}, + {m68k_op_tst_8_pi , 0xfff8, 0x4a18, 8}, + {m68k_op_tst_8_pd , 0xfff8, 0x4a20, 10}, + {m68k_op_tst_8_di , 0xfff8, 0x4a28, 12}, + {m68k_op_tst_8_ix , 0xfff8, 0x4a30, 14}, + {m68k_op_tst_16_d , 0xfff8, 0x4a40, 4}, + {m68k_op_tst_16_ai , 0xfff8, 0x4a50, 8}, + {m68k_op_tst_16_pi , 0xfff8, 0x4a58, 8}, + {m68k_op_tst_16_pd , 0xfff8, 0x4a60, 10}, + {m68k_op_tst_16_di , 0xfff8, 0x4a68, 12}, + {m68k_op_tst_16_ix , 0xfff8, 0x4a70, 14}, + {m68k_op_tst_32_d , 0xfff8, 0x4a80, 4}, + {m68k_op_tst_32_ai , 0xfff8, 0x4a90, 12}, + {m68k_op_tst_32_pi , 0xfff8, 0x4a98, 12}, + {m68k_op_tst_32_pd , 0xfff8, 0x4aa0, 14}, + {m68k_op_tst_32_di , 0xfff8, 0x4aa8, 16}, + {m68k_op_tst_32_ix , 0xfff8, 0x4ab0, 18}, + {m68k_op_tas_8_d , 0xfff8, 0x4ac0, 4}, + {m68k_op_tas_8_ai , 0xfff8, 0x4ad0, 18}, + {m68k_op_tas_8_pi , 0xfff8, 0x4ad8, 18}, + {m68k_op_tas_8_pd , 0xfff8, 0x4ae0, 20}, + {m68k_op_tas_8_di , 0xfff8, 0x4ae8, 22}, + {m68k_op_tas_8_ix , 0xfff8, 0x4af0, 24}, + {m68k_op_movem_16_er_ai , 0xfff8, 0x4c90, 12}, + {m68k_op_movem_16_er_pi , 0xfff8, 0x4c98, 12}, + {m68k_op_movem_16_er_di , 0xfff8, 0x4ca8, 16}, + {m68k_op_movem_16_er_ix , 0xfff8, 0x4cb0, 18}, + {m68k_op_movem_32_er_ai , 0xfff8, 0x4cd0, 12}, + {m68k_op_movem_32_er_pi , 0xfff8, 0x4cd8, 12}, + {m68k_op_movem_32_er_di , 0xfff8, 0x4ce8, 16}, + {m68k_op_movem_32_er_ix , 0xfff8, 0x4cf0, 18}, + {m68k_op_link_16 , 0xfff8, 0x4e50, 16}, + {m68k_op_unlk_32 , 0xfff8, 0x4e58, 12}, + {m68k_op_move_32_tou , 0xfff8, 0x4e60, 4}, + {m68k_op_move_32_fru , 0xfff8, 0x4e68, 4}, + {m68k_op_jsr_32_ai , 0xfff8, 0x4e90, 16}, + {m68k_op_jsr_32_di , 0xfff8, 0x4ea8, 18}, + {m68k_op_jsr_32_ix , 0xfff8, 0x4eb0, 22}, + {m68k_op_jmp_32_ai , 0xfff8, 0x4ed0, 8}, + {m68k_op_jmp_32_di , 0xfff8, 0x4ee8, 10}, + {m68k_op_jmp_32_ix , 0xfff8, 0x4ef0, 14}, + {m68k_op_st_8_d , 0xfff8, 0x50c0, 6}, + {m68k_op_dbt_16 , 0xfff8, 0x50c8, 12}, + {m68k_op_st_8_ai , 0xfff8, 0x50d0, 12}, + {m68k_op_st_8_pi , 0xfff8, 0x50d8, 12}, + {m68k_op_st_8_pd , 0xfff8, 0x50e0, 14}, + {m68k_op_st_8_di , 0xfff8, 0x50e8, 16}, + {m68k_op_st_8_ix , 0xfff8, 0x50f0, 18}, + {m68k_op_sf_8_d , 0xfff8, 0x51c0, 4}, + {m68k_op_dbf_16 , 0xfff8, 0x51c8, 12}, + {m68k_op_sf_8_ai , 0xfff8, 0x51d0, 12}, + {m68k_op_sf_8_pi , 0xfff8, 0x51d8, 12}, + {m68k_op_sf_8_pd , 0xfff8, 0x51e0, 14}, + {m68k_op_sf_8_di , 0xfff8, 0x51e8, 16}, + {m68k_op_sf_8_ix , 0xfff8, 0x51f0, 18}, + {m68k_op_shi_8_d , 0xfff8, 0x52c0, 4}, + {m68k_op_dbhi_16 , 0xfff8, 0x52c8, 12}, + {m68k_op_shi_8_ai , 0xfff8, 0x52d0, 12}, + {m68k_op_shi_8_pi , 0xfff8, 0x52d8, 12}, + {m68k_op_shi_8_pd , 0xfff8, 0x52e0, 14}, + {m68k_op_shi_8_di , 0xfff8, 0x52e8, 16}, + {m68k_op_shi_8_ix , 0xfff8, 0x52f0, 18}, + {m68k_op_sls_8_d , 0xfff8, 0x53c0, 4}, + {m68k_op_dbls_16 , 0xfff8, 0x53c8, 12}, + {m68k_op_sls_8_ai , 0xfff8, 0x53d0, 12}, + {m68k_op_sls_8_pi , 0xfff8, 0x53d8, 12}, + {m68k_op_sls_8_pd , 0xfff8, 0x53e0, 14}, + {m68k_op_sls_8_di , 0xfff8, 0x53e8, 16}, + {m68k_op_sls_8_ix , 0xfff8, 0x53f0, 18}, + {m68k_op_scc_8_d , 0xfff8, 0x54c0, 4}, + {m68k_op_dbcc_16 , 0xfff8, 0x54c8, 12}, + {m68k_op_scc_8_ai , 0xfff8, 0x54d0, 12}, + {m68k_op_scc_8_pi , 0xfff8, 0x54d8, 12}, + {m68k_op_scc_8_pd , 0xfff8, 0x54e0, 14}, + {m68k_op_scc_8_di , 0xfff8, 0x54e8, 16}, + {m68k_op_scc_8_ix , 0xfff8, 0x54f0, 18}, + {m68k_op_scs_8_d , 0xfff8, 0x55c0, 4}, + {m68k_op_dbcs_16 , 0xfff8, 0x55c8, 12}, + {m68k_op_scs_8_ai , 0xfff8, 0x55d0, 12}, + {m68k_op_scs_8_pi , 0xfff8, 0x55d8, 12}, + {m68k_op_scs_8_pd , 0xfff8, 0x55e0, 14}, + {m68k_op_scs_8_di , 0xfff8, 0x55e8, 16}, + {m68k_op_scs_8_ix , 0xfff8, 0x55f0, 18}, + {m68k_op_sne_8_d , 0xfff8, 0x56c0, 4}, + {m68k_op_dbne_16 , 0xfff8, 0x56c8, 12}, + {m68k_op_sne_8_ai , 0xfff8, 0x56d0, 12}, + {m68k_op_sne_8_pi , 0xfff8, 0x56d8, 12}, + {m68k_op_sne_8_pd , 0xfff8, 0x56e0, 14}, + {m68k_op_sne_8_di , 0xfff8, 0x56e8, 16}, + {m68k_op_sne_8_ix , 0xfff8, 0x56f0, 18}, + {m68k_op_seq_8_d , 0xfff8, 0x57c0, 4}, + {m68k_op_dbeq_16 , 0xfff8, 0x57c8, 12}, + {m68k_op_seq_8_ai , 0xfff8, 0x57d0, 12}, + {m68k_op_seq_8_pi , 0xfff8, 0x57d8, 12}, + {m68k_op_seq_8_pd , 0xfff8, 0x57e0, 14}, + {m68k_op_seq_8_di , 0xfff8, 0x57e8, 16}, + {m68k_op_seq_8_ix , 0xfff8, 0x57f0, 18}, + {m68k_op_svc_8_d , 0xfff8, 0x58c0, 4}, + {m68k_op_dbvc_16 , 0xfff8, 0x58c8, 12}, + {m68k_op_svc_8_ai , 0xfff8, 0x58d0, 12}, + {m68k_op_svc_8_pi , 0xfff8, 0x58d8, 12}, + {m68k_op_svc_8_pd , 0xfff8, 0x58e0, 14}, + {m68k_op_svc_8_di , 0xfff8, 0x58e8, 16}, + {m68k_op_svc_8_ix , 0xfff8, 0x58f0, 18}, + {m68k_op_svs_8_d , 0xfff8, 0x59c0, 4}, + {m68k_op_dbvs_16 , 0xfff8, 0x59c8, 12}, + {m68k_op_svs_8_ai , 0xfff8, 0x59d0, 12}, + {m68k_op_svs_8_pi , 0xfff8, 0x59d8, 12}, + {m68k_op_svs_8_pd , 0xfff8, 0x59e0, 14}, + {m68k_op_svs_8_di , 0xfff8, 0x59e8, 16}, + {m68k_op_svs_8_ix , 0xfff8, 0x59f0, 18}, + {m68k_op_spl_8_d , 0xfff8, 0x5ac0, 4}, + {m68k_op_dbpl_16 , 0xfff8, 0x5ac8, 12}, + {m68k_op_spl_8_ai , 0xfff8, 0x5ad0, 12}, + {m68k_op_spl_8_pi , 0xfff8, 0x5ad8, 12}, + {m68k_op_spl_8_pd , 0xfff8, 0x5ae0, 14}, + {m68k_op_spl_8_di , 0xfff8, 0x5ae8, 16}, + {m68k_op_spl_8_ix , 0xfff8, 0x5af0, 18}, + {m68k_op_smi_8_d , 0xfff8, 0x5bc0, 4}, + {m68k_op_dbmi_16 , 0xfff8, 0x5bc8, 12}, + {m68k_op_smi_8_ai , 0xfff8, 0x5bd0, 12}, + {m68k_op_smi_8_pi , 0xfff8, 0x5bd8, 12}, + {m68k_op_smi_8_pd , 0xfff8, 0x5be0, 14}, + {m68k_op_smi_8_di , 0xfff8, 0x5be8, 16}, + {m68k_op_smi_8_ix , 0xfff8, 0x5bf0, 18}, + {m68k_op_sge_8_d , 0xfff8, 0x5cc0, 4}, + {m68k_op_dbge_16 , 0xfff8, 0x5cc8, 12}, + {m68k_op_sge_8_ai , 0xfff8, 0x5cd0, 12}, + {m68k_op_sge_8_pi , 0xfff8, 0x5cd8, 12}, + {m68k_op_sge_8_pd , 0xfff8, 0x5ce0, 14}, + {m68k_op_sge_8_di , 0xfff8, 0x5ce8, 16}, + {m68k_op_sge_8_ix , 0xfff8, 0x5cf0, 18}, + {m68k_op_slt_8_d , 0xfff8, 0x5dc0, 4}, + {m68k_op_dblt_16 , 0xfff8, 0x5dc8, 12}, + {m68k_op_slt_8_ai , 0xfff8, 0x5dd0, 12}, + {m68k_op_slt_8_pi , 0xfff8, 0x5dd8, 12}, + {m68k_op_slt_8_pd , 0xfff8, 0x5de0, 14}, + {m68k_op_slt_8_di , 0xfff8, 0x5de8, 16}, + {m68k_op_slt_8_ix , 0xfff8, 0x5df0, 18}, + {m68k_op_sgt_8_d , 0xfff8, 0x5ec0, 4}, + {m68k_op_dbgt_16 , 0xfff8, 0x5ec8, 12}, + {m68k_op_sgt_8_ai , 0xfff8, 0x5ed0, 12}, + {m68k_op_sgt_8_pi , 0xfff8, 0x5ed8, 12}, + {m68k_op_sgt_8_pd , 0xfff8, 0x5ee0, 14}, + {m68k_op_sgt_8_di , 0xfff8, 0x5ee8, 16}, + {m68k_op_sgt_8_ix , 0xfff8, 0x5ef0, 18}, + {m68k_op_sle_8_d , 0xfff8, 0x5fc0, 4}, + {m68k_op_dble_16 , 0xfff8, 0x5fc8, 12}, + {m68k_op_sle_8_ai , 0xfff8, 0x5fd0, 12}, + {m68k_op_sle_8_pi , 0xfff8, 0x5fd8, 12}, + {m68k_op_sle_8_pd , 0xfff8, 0x5fe0, 14}, + {m68k_op_sle_8_di , 0xfff8, 0x5fe8, 16}, + {m68k_op_sle_8_ix , 0xfff8, 0x5ff0, 18}, + {m68k_op_sbcd_8_mm_ax7 , 0xfff8, 0x8f08, 18}, + {m68k_op_subx_8_mm_ax7 , 0xfff8, 0x9f08, 18}, + {m68k_op_cmpm_8_ax7 , 0xfff8, 0xbf08, 12}, + {m68k_op_abcd_8_mm_ax7 , 0xfff8, 0xcf08, 18}, + {m68k_op_addx_8_mm_ax7 , 0xfff8, 0xdf08, 18}, + {m68k_op_asr_16_ai , 0xfff8, 0xe0d0, 12}, + {m68k_op_asr_16_pi , 0xfff8, 0xe0d8, 12}, + {m68k_op_asr_16_pd , 0xfff8, 0xe0e0, 14}, + {m68k_op_asr_16_di , 0xfff8, 0xe0e8, 16}, + {m68k_op_asr_16_ix , 0xfff8, 0xe0f0, 18}, + {m68k_op_asl_16_ai , 0xfff8, 0xe1d0, 12}, + {m68k_op_asl_16_pi , 0xfff8, 0xe1d8, 12}, + {m68k_op_asl_16_pd , 0xfff8, 0xe1e0, 14}, + {m68k_op_asl_16_di , 0xfff8, 0xe1e8, 16}, + {m68k_op_asl_16_ix , 0xfff8, 0xe1f0, 18}, + {m68k_op_lsr_16_ai , 0xfff8, 0xe2d0, 12}, + {m68k_op_lsr_16_pi , 0xfff8, 0xe2d8, 12}, + {m68k_op_lsr_16_pd , 0xfff8, 0xe2e0, 14}, + {m68k_op_lsr_16_di , 0xfff8, 0xe2e8, 16}, + {m68k_op_lsr_16_ix , 0xfff8, 0xe2f0, 18}, + {m68k_op_lsl_16_ai , 0xfff8, 0xe3d0, 12}, + {m68k_op_lsl_16_pi , 0xfff8, 0xe3d8, 12}, + {m68k_op_lsl_16_pd , 0xfff8, 0xe3e0, 14}, + {m68k_op_lsl_16_di , 0xfff8, 0xe3e8, 16}, + {m68k_op_lsl_16_ix , 0xfff8, 0xe3f0, 18}, + {m68k_op_roxr_16_ai , 0xfff8, 0xe4d0, 12}, + {m68k_op_roxr_16_pi , 0xfff8, 0xe4d8, 12}, + {m68k_op_roxr_16_pd , 0xfff8, 0xe4e0, 14}, + {m68k_op_roxr_16_di , 0xfff8, 0xe4e8, 16}, + {m68k_op_roxr_16_ix , 0xfff8, 0xe4f0, 18}, + {m68k_op_roxl_16_ai , 0xfff8, 0xe5d0, 12}, + {m68k_op_roxl_16_pi , 0xfff8, 0xe5d8, 12}, + {m68k_op_roxl_16_pd , 0xfff8, 0xe5e0, 14}, + {m68k_op_roxl_16_di , 0xfff8, 0xe5e8, 16}, + {m68k_op_roxl_16_ix , 0xfff8, 0xe5f0, 18}, + {m68k_op_ror_16_ai , 0xfff8, 0xe6d0, 12}, + {m68k_op_ror_16_pi , 0xfff8, 0xe6d8, 12}, + {m68k_op_ror_16_pd , 0xfff8, 0xe6e0, 14}, + {m68k_op_ror_16_di , 0xfff8, 0xe6e8, 16}, + {m68k_op_ror_16_ix , 0xfff8, 0xe6f0, 18}, + {m68k_op_rol_16_ai , 0xfff8, 0xe7d0, 12}, + {m68k_op_rol_16_pi , 0xfff8, 0xe7d8, 12}, + {m68k_op_rol_16_pd , 0xfff8, 0xe7e0, 14}, + {m68k_op_rol_16_di , 0xfff8, 0xe7e8, 16}, + {m68k_op_rol_16_ix , 0xfff8, 0xe7f0, 18}, + {m68k_op_ori_8_pi7 , 0xffff, 0x001f, 16}, + {m68k_op_ori_8_pd7 , 0xffff, 0x0027, 18}, + {m68k_op_ori_8_aw , 0xffff, 0x0038, 20}, + {m68k_op_ori_8_al , 0xffff, 0x0039, 24}, + {m68k_op_ori_16_toc , 0xffff, 0x003c, 20}, + {m68k_op_ori_16_aw , 0xffff, 0x0078, 20}, + {m68k_op_ori_16_al , 0xffff, 0x0079, 24}, + {m68k_op_ori_16_tos , 0xffff, 0x007c, 20}, + {m68k_op_ori_32_aw , 0xffff, 0x00b8, 32}, + {m68k_op_ori_32_al , 0xffff, 0x00b9, 36}, + {m68k_op_andi_8_pi7 , 0xffff, 0x021f, 16}, + {m68k_op_andi_8_pd7 , 0xffff, 0x0227, 18}, + {m68k_op_andi_8_aw , 0xffff, 0x0238, 20}, + {m68k_op_andi_8_al , 0xffff, 0x0239, 24}, + {m68k_op_andi_16_toc , 0xffff, 0x023c, 20}, + {m68k_op_andi_16_aw , 0xffff, 0x0278, 20}, + {m68k_op_andi_16_al , 0xffff, 0x0279, 24}, + {m68k_op_andi_16_tos , 0xffff, 0x027c, 20}, + {m68k_op_andi_32_aw , 0xffff, 0x02b8, 32}, + {m68k_op_andi_32_al , 0xffff, 0x02b9, 36}, + {m68k_op_subi_8_pi7 , 0xffff, 0x041f, 16}, + {m68k_op_subi_8_pd7 , 0xffff, 0x0427, 18}, + {m68k_op_subi_8_aw , 0xffff, 0x0438, 20}, + {m68k_op_subi_8_al , 0xffff, 0x0439, 24}, + {m68k_op_subi_16_aw , 0xffff, 0x0478, 20}, + {m68k_op_subi_16_al , 0xffff, 0x0479, 24}, + {m68k_op_subi_32_aw , 0xffff, 0x04b8, 32}, + {m68k_op_subi_32_al , 0xffff, 0x04b9, 36}, + {m68k_op_addi_8_pi7 , 0xffff, 0x061f, 16}, + {m68k_op_addi_8_pd7 , 0xffff, 0x0627, 18}, + {m68k_op_addi_8_aw , 0xffff, 0x0638, 20}, + {m68k_op_addi_8_al , 0xffff, 0x0639, 24}, + {m68k_op_addi_16_aw , 0xffff, 0x0678, 20}, + {m68k_op_addi_16_al , 0xffff, 0x0679, 24}, + {m68k_op_addi_32_aw , 0xffff, 0x06b8, 32}, + {m68k_op_addi_32_al , 0xffff, 0x06b9, 36}, + {m68k_op_btst_8_s_pi7 , 0xffff, 0x081f, 12}, + {m68k_op_btst_8_s_pd7 , 0xffff, 0x0827, 14}, + {m68k_op_btst_8_s_aw , 0xffff, 0x0838, 16}, + {m68k_op_btst_8_s_al , 0xffff, 0x0839, 20}, + {m68k_op_btst_8_s_pcdi , 0xffff, 0x083a, 16}, + {m68k_op_btst_8_s_pcix , 0xffff, 0x083b, 18}, + {m68k_op_bchg_8_s_pi7 , 0xffff, 0x085f, 16}, + {m68k_op_bchg_8_s_pd7 , 0xffff, 0x0867, 18}, + {m68k_op_bchg_8_s_aw , 0xffff, 0x0878, 20}, + {m68k_op_bchg_8_s_al , 0xffff, 0x0879, 24}, + {m68k_op_bclr_8_s_pi7 , 0xffff, 0x089f, 16}, + {m68k_op_bclr_8_s_pd7 , 0xffff, 0x08a7, 18}, + {m68k_op_bclr_8_s_aw , 0xffff, 0x08b8, 20}, + {m68k_op_bclr_8_s_al , 0xffff, 0x08b9, 24}, + {m68k_op_bset_8_s_pi7 , 0xffff, 0x08df, 16}, + {m68k_op_bset_8_s_pd7 , 0xffff, 0x08e7, 18}, + {m68k_op_bset_8_s_aw , 0xffff, 0x08f8, 20}, + {m68k_op_bset_8_s_al , 0xffff, 0x08f9, 24}, + {m68k_op_eori_8_pi7 , 0xffff, 0x0a1f, 16}, + {m68k_op_eori_8_pd7 , 0xffff, 0x0a27, 18}, + {m68k_op_eori_8_aw , 0xffff, 0x0a38, 20}, + {m68k_op_eori_8_al , 0xffff, 0x0a39, 24}, + {m68k_op_eori_16_toc , 0xffff, 0x0a3c, 20}, + {m68k_op_eori_16_aw , 0xffff, 0x0a78, 20}, + {m68k_op_eori_16_al , 0xffff, 0x0a79, 24}, + {m68k_op_eori_16_tos , 0xffff, 0x0a7c, 20}, + {m68k_op_eori_32_aw , 0xffff, 0x0ab8, 32}, + {m68k_op_eori_32_al , 0xffff, 0x0ab9, 36}, + {m68k_op_cmpi_8_pi7 , 0xffff, 0x0c1f, 12}, + {m68k_op_cmpi_8_pd7 , 0xffff, 0x0c27, 14}, + {m68k_op_cmpi_8_aw , 0xffff, 0x0c38, 16}, + {m68k_op_cmpi_8_al , 0xffff, 0x0c39, 20}, + {m68k_op_cmpi_16_aw , 0xffff, 0x0c78, 16}, + {m68k_op_cmpi_16_al , 0xffff, 0x0c79, 20}, + {m68k_op_cmpi_32_aw , 0xffff, 0x0cb8, 24}, + {m68k_op_cmpi_32_al , 0xffff, 0x0cb9, 28}, + {m68k_op_move_8_aw_pi7 , 0xffff, 0x11df, 16}, + {m68k_op_move_8_aw_pd7 , 0xffff, 0x11e7, 18}, + {m68k_op_move_8_aw_aw , 0xffff, 0x11f8, 20}, + {m68k_op_move_8_aw_al , 0xffff, 0x11f9, 24}, + {m68k_op_move_8_aw_pcdi , 0xffff, 0x11fa, 20}, + {m68k_op_move_8_aw_pcix , 0xffff, 0x11fb, 22}, + {m68k_op_move_8_aw_i , 0xffff, 0x11fc, 16}, + {m68k_op_move_8_al_pi7 , 0xffff, 0x13df, 20}, + {m68k_op_move_8_al_pd7 , 0xffff, 0x13e7, 22}, + {m68k_op_move_8_al_aw , 0xffff, 0x13f8, 24}, + {m68k_op_move_8_al_al , 0xffff, 0x13f9, 28}, + {m68k_op_move_8_al_pcdi , 0xffff, 0x13fa, 24}, + {m68k_op_move_8_al_pcix , 0xffff, 0x13fb, 26}, + {m68k_op_move_8_al_i , 0xffff, 0x13fc, 20}, + {m68k_op_move_8_pi7_pi7 , 0xffff, 0x1edf, 12}, + {m68k_op_move_8_pi7_pd7 , 0xffff, 0x1ee7, 14}, + {m68k_op_move_8_pi7_aw , 0xffff, 0x1ef8, 16}, + {m68k_op_move_8_pi7_al , 0xffff, 0x1ef9, 20}, + {m68k_op_move_8_pi7_pcdi , 0xffff, 0x1efa, 16}, + {m68k_op_move_8_pi7_pcix , 0xffff, 0x1efb, 18}, + {m68k_op_move_8_pi7_i , 0xffff, 0x1efc, 12}, + {m68k_op_move_8_pd7_pi7 , 0xffff, 0x1f1f, 12}, + {m68k_op_move_8_pd7_pd7 , 0xffff, 0x1f27, 14}, + {m68k_op_move_8_pd7_aw , 0xffff, 0x1f38, 16}, + {m68k_op_move_8_pd7_al , 0xffff, 0x1f39, 20}, + {m68k_op_move_8_pd7_pcdi , 0xffff, 0x1f3a, 16}, + {m68k_op_move_8_pd7_pcix , 0xffff, 0x1f3b, 18}, + {m68k_op_move_8_pd7_i , 0xffff, 0x1f3c, 12}, + {m68k_op_move_32_aw_aw , 0xffff, 0x21f8, 28}, + {m68k_op_move_32_aw_al , 0xffff, 0x21f9, 32}, + {m68k_op_move_32_aw_pcdi , 0xffff, 0x21fa, 28}, + {m68k_op_move_32_aw_pcix , 0xffff, 0x21fb, 30}, + {m68k_op_move_32_aw_i , 0xffff, 0x21fc, 24}, + {m68k_op_move_32_al_aw , 0xffff, 0x23f8, 32}, + {m68k_op_move_32_al_al , 0xffff, 0x23f9, 36}, + {m68k_op_move_32_al_pcdi , 0xffff, 0x23fa, 32}, + {m68k_op_move_32_al_pcix , 0xffff, 0x23fb, 34}, + {m68k_op_move_32_al_i , 0xffff, 0x23fc, 28}, + {m68k_op_move_16_aw_aw , 0xffff, 0x31f8, 20}, + {m68k_op_move_16_aw_al , 0xffff, 0x31f9, 24}, + {m68k_op_move_16_aw_pcdi , 0xffff, 0x31fa, 20}, + {m68k_op_move_16_aw_pcix , 0xffff, 0x31fb, 22}, + {m68k_op_move_16_aw_i , 0xffff, 0x31fc, 16}, + {m68k_op_move_16_al_aw , 0xffff, 0x33f8, 24}, + {m68k_op_move_16_al_al , 0xffff, 0x33f9, 28}, + {m68k_op_move_16_al_pcdi , 0xffff, 0x33fa, 24}, + {m68k_op_move_16_al_pcix , 0xffff, 0x33fb, 26}, + {m68k_op_move_16_al_i , 0xffff, 0x33fc, 20}, + {m68k_op_negx_8_pi7 , 0xffff, 0x401f, 12}, + {m68k_op_negx_8_pd7 , 0xffff, 0x4027, 14}, + {m68k_op_negx_8_aw , 0xffff, 0x4038, 16}, + {m68k_op_negx_8_al , 0xffff, 0x4039, 20}, + {m68k_op_negx_16_aw , 0xffff, 0x4078, 16}, + {m68k_op_negx_16_al , 0xffff, 0x4079, 20}, + {m68k_op_negx_32_aw , 0xffff, 0x40b8, 24}, + {m68k_op_negx_32_al , 0xffff, 0x40b9, 28}, + {m68k_op_move_16_frs_aw , 0xffff, 0x40f8, 16}, + {m68k_op_move_16_frs_al , 0xffff, 0x40f9, 20}, + {m68k_op_clr_8_pi7 , 0xffff, 0x421f, 12}, + {m68k_op_clr_8_pd7 , 0xffff, 0x4227, 14}, + {m68k_op_clr_8_aw , 0xffff, 0x4238, 16}, + {m68k_op_clr_8_al , 0xffff, 0x4239, 20}, + {m68k_op_clr_16_aw , 0xffff, 0x4278, 16}, + {m68k_op_clr_16_al , 0xffff, 0x4279, 20}, + {m68k_op_clr_32_aw , 0xffff, 0x42b8, 24}, + {m68k_op_clr_32_al , 0xffff, 0x42b9, 28}, + {m68k_op_neg_8_pi7 , 0xffff, 0x441f, 12}, + {m68k_op_neg_8_pd7 , 0xffff, 0x4427, 14}, + {m68k_op_neg_8_aw , 0xffff, 0x4438, 16}, + {m68k_op_neg_8_al , 0xffff, 0x4439, 20}, + {m68k_op_neg_16_aw , 0xffff, 0x4478, 16}, + {m68k_op_neg_16_al , 0xffff, 0x4479, 20}, + {m68k_op_neg_32_aw , 0xffff, 0x44b8, 24}, + {m68k_op_neg_32_al , 0xffff, 0x44b9, 28}, + {m68k_op_move_16_toc_aw , 0xffff, 0x44f8, 20}, + {m68k_op_move_16_toc_al , 0xffff, 0x44f9, 24}, + {m68k_op_move_16_toc_pcdi , 0xffff, 0x44fa, 20}, + {m68k_op_move_16_toc_pcix , 0xffff, 0x44fb, 22}, + {m68k_op_move_16_toc_i , 0xffff, 0x44fc, 16}, + {m68k_op_not_8_pi7 , 0xffff, 0x461f, 12}, + {m68k_op_not_8_pd7 , 0xffff, 0x4627, 14}, + {m68k_op_not_8_aw , 0xffff, 0x4638, 16}, + {m68k_op_not_8_al , 0xffff, 0x4639, 20}, + {m68k_op_not_16_aw , 0xffff, 0x4678, 16}, + {m68k_op_not_16_al , 0xffff, 0x4679, 20}, + {m68k_op_not_32_aw , 0xffff, 0x46b8, 24}, + {m68k_op_not_32_al , 0xffff, 0x46b9, 28}, + {m68k_op_move_16_tos_aw , 0xffff, 0x46f8, 20}, + {m68k_op_move_16_tos_al , 0xffff, 0x46f9, 24}, + {m68k_op_move_16_tos_pcdi , 0xffff, 0x46fa, 20}, + {m68k_op_move_16_tos_pcix , 0xffff, 0x46fb, 22}, + {m68k_op_move_16_tos_i , 0xffff, 0x46fc, 16}, + {m68k_op_nbcd_8_pi7 , 0xffff, 0x481f, 12}, + {m68k_op_nbcd_8_pd7 , 0xffff, 0x4827, 14}, + {m68k_op_nbcd_8_aw , 0xffff, 0x4838, 16}, + {m68k_op_nbcd_8_al , 0xffff, 0x4839, 20}, + {m68k_op_pea_32_aw , 0xffff, 0x4878, 16}, + {m68k_op_pea_32_al , 0xffff, 0x4879, 20}, + {m68k_op_pea_32_pcdi , 0xffff, 0x487a, 16}, + {m68k_op_pea_32_pcix , 0xffff, 0x487b, 20}, + {m68k_op_movem_16_re_aw , 0xffff, 0x48b8, 12}, + {m68k_op_movem_16_re_al , 0xffff, 0x48b9, 16}, + {m68k_op_movem_32_re_aw , 0xffff, 0x48f8, 12}, + {m68k_op_movem_32_re_al , 0xffff, 0x48f9, 16}, + {m68k_op_tst_8_pi7 , 0xffff, 0x4a1f, 8}, + {m68k_op_tst_8_pd7 , 0xffff, 0x4a27, 10}, + {m68k_op_tst_8_aw , 0xffff, 0x4a38, 12}, + {m68k_op_tst_8_al , 0xffff, 0x4a39, 16}, + {m68k_op_tst_16_aw , 0xffff, 0x4a78, 12}, + {m68k_op_tst_16_al , 0xffff, 0x4a79, 16}, + {m68k_op_tst_32_aw , 0xffff, 0x4ab8, 16}, + {m68k_op_tst_32_al , 0xffff, 0x4ab9, 20}, + {m68k_op_tas_8_pi7 , 0xffff, 0x4adf, 18}, + {m68k_op_tas_8_pd7 , 0xffff, 0x4ae7, 20}, + {m68k_op_tas_8_aw , 0xffff, 0x4af8, 22}, + {m68k_op_tas_8_al , 0xffff, 0x4af9, 26}, + {m68k_op_illegal , 0xffff, 0x4afc, 4}, + {m68k_op_movem_16_er_aw , 0xffff, 0x4cb8, 16}, + {m68k_op_movem_16_er_al , 0xffff, 0x4cb9, 20}, + {m68k_op_movem_16_er_pcdi , 0xffff, 0x4cba, 16}, + {m68k_op_movem_16_er_pcix , 0xffff, 0x4cbb, 18}, + {m68k_op_movem_32_er_aw , 0xffff, 0x4cf8, 16}, + {m68k_op_movem_32_er_al , 0xffff, 0x4cf9, 20}, + {m68k_op_movem_32_er_pcdi , 0xffff, 0x4cfa, 16}, + {m68k_op_movem_32_er_pcix , 0xffff, 0x4cfb, 18}, + {m68k_op_link_16_a7 , 0xffff, 0x4e57, 16}, + {m68k_op_unlk_32_a7 , 0xffff, 0x4e5f, 12}, + {m68k_op_reset , 0xffff, 0x4e70, 0}, + {m68k_op_nop , 0xffff, 0x4e71, 4}, + {m68k_op_stop , 0xffff, 0x4e72, 4}, + {m68k_op_rte_32 , 0xffff, 0x4e73, 20}, + {m68k_op_rts_32 , 0xffff, 0x4e75, 16}, + {m68k_op_trapv , 0xffff, 0x4e76, 4}, + {m68k_op_rtr_32 , 0xffff, 0x4e77, 20}, + {m68k_op_jsr_32_aw , 0xffff, 0x4eb8, 18}, + {m68k_op_jsr_32_al , 0xffff, 0x4eb9, 20}, + {m68k_op_jsr_32_pcdi , 0xffff, 0x4eba, 18}, + {m68k_op_jsr_32_pcix , 0xffff, 0x4ebb, 22}, + {m68k_op_jmp_32_aw , 0xffff, 0x4ef8, 10}, + {m68k_op_jmp_32_al , 0xffff, 0x4ef9, 12}, + {m68k_op_jmp_32_pcdi , 0xffff, 0x4efa, 10}, + {m68k_op_jmp_32_pcix , 0xffff, 0x4efb, 14}, + {m68k_op_st_8_pi7 , 0xffff, 0x50df, 12}, + {m68k_op_st_8_pd7 , 0xffff, 0x50e7, 14}, + {m68k_op_st_8_aw , 0xffff, 0x50f8, 16}, + {m68k_op_st_8_al , 0xffff, 0x50f9, 20}, + {m68k_op_sf_8_pi7 , 0xffff, 0x51df, 12}, + {m68k_op_sf_8_pd7 , 0xffff, 0x51e7, 14}, + {m68k_op_sf_8_aw , 0xffff, 0x51f8, 16}, + {m68k_op_sf_8_al , 0xffff, 0x51f9, 20}, + {m68k_op_shi_8_pi7 , 0xffff, 0x52df, 12}, + {m68k_op_shi_8_pd7 , 0xffff, 0x52e7, 14}, + {m68k_op_shi_8_aw , 0xffff, 0x52f8, 16}, + {m68k_op_shi_8_al , 0xffff, 0x52f9, 20}, + {m68k_op_sls_8_pi7 , 0xffff, 0x53df, 12}, + {m68k_op_sls_8_pd7 , 0xffff, 0x53e7, 14}, + {m68k_op_sls_8_aw , 0xffff, 0x53f8, 16}, + {m68k_op_sls_8_al , 0xffff, 0x53f9, 20}, + {m68k_op_scc_8_pi7 , 0xffff, 0x54df, 12}, + {m68k_op_scc_8_pd7 , 0xffff, 0x54e7, 14}, + {m68k_op_scc_8_aw , 0xffff, 0x54f8, 16}, + {m68k_op_scc_8_al , 0xffff, 0x54f9, 20}, + {m68k_op_scs_8_pi7 , 0xffff, 0x55df, 12}, + {m68k_op_scs_8_pd7 , 0xffff, 0x55e7, 14}, + {m68k_op_scs_8_aw , 0xffff, 0x55f8, 16}, + {m68k_op_scs_8_al , 0xffff, 0x55f9, 20}, + {m68k_op_sne_8_pi7 , 0xffff, 0x56df, 12}, + {m68k_op_sne_8_pd7 , 0xffff, 0x56e7, 14}, + {m68k_op_sne_8_aw , 0xffff, 0x56f8, 16}, + {m68k_op_sne_8_al , 0xffff, 0x56f9, 20}, + {m68k_op_seq_8_pi7 , 0xffff, 0x57df, 12}, + {m68k_op_seq_8_pd7 , 0xffff, 0x57e7, 14}, + {m68k_op_seq_8_aw , 0xffff, 0x57f8, 16}, + {m68k_op_seq_8_al , 0xffff, 0x57f9, 20}, + {m68k_op_svc_8_pi7 , 0xffff, 0x58df, 12}, + {m68k_op_svc_8_pd7 , 0xffff, 0x58e7, 14}, + {m68k_op_svc_8_aw , 0xffff, 0x58f8, 16}, + {m68k_op_svc_8_al , 0xffff, 0x58f9, 20}, + {m68k_op_svs_8_pi7 , 0xffff, 0x59df, 12}, + {m68k_op_svs_8_pd7 , 0xffff, 0x59e7, 14}, + {m68k_op_svs_8_aw , 0xffff, 0x59f8, 16}, + {m68k_op_svs_8_al , 0xffff, 0x59f9, 20}, + {m68k_op_spl_8_pi7 , 0xffff, 0x5adf, 12}, + {m68k_op_spl_8_pd7 , 0xffff, 0x5ae7, 14}, + {m68k_op_spl_8_aw , 0xffff, 0x5af8, 16}, + {m68k_op_spl_8_al , 0xffff, 0x5af9, 20}, + {m68k_op_smi_8_pi7 , 0xffff, 0x5bdf, 12}, + {m68k_op_smi_8_pd7 , 0xffff, 0x5be7, 14}, + {m68k_op_smi_8_aw , 0xffff, 0x5bf8, 16}, + {m68k_op_smi_8_al , 0xffff, 0x5bf9, 20}, + {m68k_op_sge_8_pi7 , 0xffff, 0x5cdf, 12}, + {m68k_op_sge_8_pd7 , 0xffff, 0x5ce7, 14}, + {m68k_op_sge_8_aw , 0xffff, 0x5cf8, 16}, + {m68k_op_sge_8_al , 0xffff, 0x5cf9, 20}, + {m68k_op_slt_8_pi7 , 0xffff, 0x5ddf, 12}, + {m68k_op_slt_8_pd7 , 0xffff, 0x5de7, 14}, + {m68k_op_slt_8_aw , 0xffff, 0x5df8, 16}, + {m68k_op_slt_8_al , 0xffff, 0x5df9, 20}, + {m68k_op_sgt_8_pi7 , 0xffff, 0x5edf, 12}, + {m68k_op_sgt_8_pd7 , 0xffff, 0x5ee7, 14}, + {m68k_op_sgt_8_aw , 0xffff, 0x5ef8, 16}, + {m68k_op_sgt_8_al , 0xffff, 0x5ef9, 20}, + {m68k_op_sle_8_pi7 , 0xffff, 0x5fdf, 12}, + {m68k_op_sle_8_pd7 , 0xffff, 0x5fe7, 14}, + {m68k_op_sle_8_aw , 0xffff, 0x5ff8, 16}, + {m68k_op_sle_8_al , 0xffff, 0x5ff9, 20}, + {m68k_op_bra_16 , 0xffff, 0x6000, 10}, + {m68k_op_bra_32 , 0xffff, 0x60ff, 10}, + {m68k_op_bsr_16 , 0xffff, 0x6100, 18}, + {m68k_op_bsr_32 , 0xffff, 0x61ff, 18}, + {m68k_op_bhi_16 , 0xffff, 0x6200, 10}, + {m68k_op_bhi_32 , 0xffff, 0x62ff, 10}, + {m68k_op_bls_16 , 0xffff, 0x6300, 10}, + {m68k_op_bls_32 , 0xffff, 0x63ff, 10}, + {m68k_op_bcc_16 , 0xffff, 0x6400, 10}, + {m68k_op_bcc_32 , 0xffff, 0x64ff, 10}, + {m68k_op_bcs_16 , 0xffff, 0x6500, 10}, + {m68k_op_bcs_32 , 0xffff, 0x65ff, 10}, + {m68k_op_bne_16 , 0xffff, 0x6600, 10}, + {m68k_op_bne_32 , 0xffff, 0x66ff, 10}, + {m68k_op_beq_16 , 0xffff, 0x6700, 10}, + {m68k_op_beq_32 , 0xffff, 0x67ff, 10}, + {m68k_op_bvc_16 , 0xffff, 0x6800, 10}, + {m68k_op_bvc_32 , 0xffff, 0x68ff, 10}, + {m68k_op_bvs_16 , 0xffff, 0x6900, 10}, + {m68k_op_bvs_32 , 0xffff, 0x69ff, 10}, + {m68k_op_bpl_16 , 0xffff, 0x6a00, 10}, + {m68k_op_bpl_32 , 0xffff, 0x6aff, 10}, + {m68k_op_bmi_16 , 0xffff, 0x6b00, 10}, + {m68k_op_bmi_32 , 0xffff, 0x6bff, 10}, + {m68k_op_bge_16 , 0xffff, 0x6c00, 10}, + {m68k_op_bge_32 , 0xffff, 0x6cff, 10}, + {m68k_op_blt_16 , 0xffff, 0x6d00, 10}, + {m68k_op_blt_32 , 0xffff, 0x6dff, 10}, + {m68k_op_bgt_16 , 0xffff, 0x6e00, 10}, + {m68k_op_bgt_32 , 0xffff, 0x6eff, 10}, + {m68k_op_ble_16 , 0xffff, 0x6f00, 10}, + {m68k_op_ble_32 , 0xffff, 0x6fff, 10}, + {m68k_op_sbcd_8_mm_axy7 , 0xffff, 0x8f0f, 18}, + {m68k_op_subx_8_mm_axy7 , 0xffff, 0x9f0f, 18}, + {m68k_op_cmpm_8_axy7 , 0xffff, 0xbf0f, 12}, + {m68k_op_abcd_8_mm_axy7 , 0xffff, 0xcf0f, 18}, + {m68k_op_addx_8_mm_axy7 , 0xffff, 0xdf0f, 18}, + {m68k_op_asr_16_aw , 0xffff, 0xe0f8, 16}, + {m68k_op_asr_16_al , 0xffff, 0xe0f9, 20}, + {m68k_op_asl_16_aw , 0xffff, 0xe1f8, 16}, + {m68k_op_asl_16_al , 0xffff, 0xe1f9, 20}, + {m68k_op_lsr_16_aw , 0xffff, 0xe2f8, 16}, + {m68k_op_lsr_16_al , 0xffff, 0xe2f9, 20}, + {m68k_op_lsl_16_aw , 0xffff, 0xe3f8, 16}, + {m68k_op_lsl_16_al , 0xffff, 0xe3f9, 20}, + {m68k_op_roxr_16_aw , 0xffff, 0xe4f8, 16}, + {m68k_op_roxr_16_al , 0xffff, 0xe4f9, 20}, + {m68k_op_roxl_16_aw , 0xffff, 0xe5f8, 16}, + {m68k_op_roxl_16_al , 0xffff, 0xe5f9, 20}, + {m68k_op_ror_16_aw , 0xffff, 0xe6f8, 16}, + {m68k_op_ror_16_al , 0xffff, 0xe6f9, 20}, + {m68k_op_rol_16_aw , 0xffff, 0xe7f8, 16}, + {m68k_op_rol_16_al , 0xffff, 0xe7f9, 20}, + {0, 0, 0, 0} +}; + + +/* Build the opcode handler jump table */ +static void m68ki_build_opcode_table(void) +{ + const opcode_handler_struct *ostruct; + int instr; + int i; + int j; + + for(i = 0; i < 0x10000; i++) + { + /* default to illegal */ + m68ki_instruction_jump_table[i] = m68k_op_illegal; + m68ki_cycles[i] = 0; + } + + ostruct = &m68k_opcode_handler_table[0]; + while(ostruct->mask != 0xff00) + { + for(i = 0;i < 0x10000;i++) + { + if((i & ostruct->mask) == ostruct->match) + { + m68ki_instruction_jump_table[i] = ostruct->opcode_handler; + m68ki_cycles[i] = ostruct->cycles * 7; + } + } + ostruct++; + } + while(ostruct->mask == 0xff00) + { + for(i = 0;i <= 0xff;i++) + { + m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; + m68ki_cycles[ostruct->match | i] = ostruct->cycles * 7; + } + ostruct++; + } + while(ostruct->mask == 0xf1f8) + { + for(i = 0;i < 8;i++) + { + for(j = 0;j < 8;j++) + { + instr = ostruct->match | (i << 9) | j; + m68ki_instruction_jump_table[instr] = ostruct->opcode_handler; + m68ki_cycles[instr] = ostruct->cycles * 7; + } + } + ostruct++; + } + while(ostruct->mask == 0xfff0) + { + for(i = 0;i <= 0x0f;i++) + { + m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; + m68ki_cycles[ostruct->match | i] = ostruct->cycles * 7; + } + ostruct++; + } + while(ostruct->mask == 0xf1ff) + { + for(i = 0;i <= 0x07;i++) + { + m68ki_instruction_jump_table[ostruct->match | (i << 9)] = ostruct->opcode_handler; + m68ki_cycles[ostruct->match | (i << 9)] = ostruct->cycles * 7; + } + ostruct++; + } + while(ostruct->mask == 0xfff8) + { + for(i = 0;i <= 0x07;i++) + { + m68ki_instruction_jump_table[ostruct->match | i] = ostruct->opcode_handler; + m68ki_cycles[ostruct->match | i] = ostruct->cycles * 7; + } + ostruct++; + } + while(ostruct->mask == 0xffff) + { + m68ki_instruction_jump_table[ostruct->match] = ostruct->opcode_handler; + m68ki_cycles[ostruct->match] = ostruct->cycles * 7; + ostruct++; + } +} /* ======================================================================== */ /* ============================== END OF FILE ============================= */ /* ======================================================================== */ -#endif /* M68KOPS__HEADER */ - diff --git a/source/mem68k.c b/source/mem68k.c index 5274d08..b65b52a 100644 --- a/source/mem68k.c +++ b/source/mem68k.c @@ -1,28 +1,44 @@ /*************************************************************************************** * Genesis Plus - * 68k bus controller + * 68k bus handlers * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ -#include "m68kcpu.h" #include "shared.h" +#include "m68kcpu.h" /*--------------------------------------------------------------------------*/ @@ -31,7 +47,7 @@ unsigned int m68k_read_bus_8(unsigned int address) { #ifdef LOGERROR - error("Unused read8 %08X (%08X)\n", address, m68k_get_reg (NULL, M68K_REG_PC)); + error("Unused read8 %08X (%08X)\n", address, m68k_get_reg(M68K_REG_PC)); #endif return m68k_read_pcrelative_8(REG_PC | (address & 1)); } @@ -39,7 +55,7 @@ unsigned int m68k_read_bus_8(unsigned int address) unsigned int m68k_read_bus_16(unsigned int address) { #ifdef LOGERROR - error("Unused read16 %08X (%08X)\n", address, m68k_get_reg (NULL, M68K_REG_PC)); + error("Unused read16 %08X (%08X)\n", address, m68k_get_reg(M68K_REG_PC)); #endif return m68k_read_pcrelative_16(REG_PC); } @@ -48,14 +64,14 @@ unsigned int m68k_read_bus_16(unsigned int address) void m68k_unused_8_w (unsigned int address, unsigned int data) { #ifdef LOGERROR - error("Unused write8 %08X = %02X (%08X)\n", address, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("Unused write8 %08X = %02X (%08X)\n", address, data, m68k_get_reg(M68K_REG_PC)); #endif } void m68k_unused_16_w (unsigned int address, unsigned int data) { #ifdef LOGERROR - error("Unused write16 %08X = %04X (%08X)\n", address, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("Unused write16 %08X = %04X (%08X)\n", address, data, m68k_get_reg(M68K_REG_PC)); #endif } @@ -66,7 +82,7 @@ void m68k_unused_16_w (unsigned int address, unsigned int data) void m68k_lockup_w_8 (unsigned int address, unsigned int data) { #ifdef LOGERROR - error ("Lockup %08X = %02X (%08X)\n", address, data, m68k_get_reg (NULL, M68K_REG_PC)); + error ("Lockup %08X = %02X (%08X)\n", address, data, m68k_get_reg(M68K_REG_PC)); #endif if (!config.force_dtack) { @@ -77,7 +93,7 @@ void m68k_lockup_w_8 (unsigned int address, unsigned int data) void m68k_lockup_w_16 (unsigned int address, unsigned int data) { #ifdef LOGERROR - error ("Lockup %08X = %04X (%08X)\n", address, data, m68k_get_reg (NULL, M68K_REG_PC)); + error ("Lockup %08X = %04X (%08X)\n", address, data, m68k_get_reg(M68K_REG_PC)); #endif if (!config.force_dtack) { @@ -88,7 +104,7 @@ void m68k_lockup_w_16 (unsigned int address, unsigned int data) unsigned int m68k_lockup_r_8 (unsigned int address) { #ifdef LOGERROR - error ("Lockup %08X.b (%08X)\n", address, m68k_get_reg (NULL, M68K_REG_PC)); + error ("Lockup %08X.b (%08X)\n", address, m68k_get_reg(M68K_REG_PC)); #endif if (!config.force_dtack) { @@ -100,7 +116,7 @@ unsigned int m68k_lockup_r_8 (unsigned int address) unsigned int m68k_lockup_r_16 (unsigned int address) { #ifdef LOGERROR - error ("Lockup %08X.w (%08X)\n", address, m68k_get_reg (NULL, M68K_REG_PC)); + error ("Lockup %08X.w (%08X)\n", address, m68k_get_reg(M68K_REG_PC)); #endif if (!config.force_dtack) { @@ -110,48 +126,6 @@ unsigned int m68k_lockup_r_16 (unsigned int address) } -/*--------------------------------------------------------------------------*/ -/* cartridge EEPROM */ -/*--------------------------------------------------------------------------*/ -unsigned int eeprom_read_byte(unsigned int address) -{ - if (address == eeprom.type.sda_out_adr) - { - return eeprom_read(0); - } - return READ_BYTE(cart.rom, address); -} - -unsigned int eeprom_read_word(unsigned int address) -{ - if (address == (eeprom.type.sda_out_adr & 0xFFFFFE)) - { - return eeprom_read(1); - } - return *(uint16 *)(cart.rom + address); -} - -void eeprom_write_byte(unsigned int address, unsigned int data) -{ - if ((address == eeprom.type.sda_in_adr) || (address == eeprom.type.scl_adr)) - { - eeprom_write(address, data, 0); - return; - } - m68k_unused_8_w(address, data); -} - -void eeprom_write_word(unsigned int address, unsigned int data) -{ - if ((address == (eeprom.type.sda_in_adr & 0xFFFFFE)) || (address == (eeprom.type.scl_adr & 0xFFFFFE))) - { - eeprom_write(address, data, 1); - return; - } - m68k_unused_16_w (address, data); -} - - /*--------------------------------------------------------------------------*/ /* Z80 bus (accessed through I/O chip) */ /*--------------------------------------------------------------------------*/ @@ -256,6 +230,7 @@ unsigned int ctrl_io_read_byte(unsigned int address) { if (!(address & 1)) { + /* Unused bits return prefetched bus data (Time Killers) */ unsigned int data = m68k_read_pcrelative_8(REG_PC) & 0xFE; if (zstate == 3) { @@ -323,6 +298,7 @@ unsigned int ctrl_io_read_word(unsigned int address) case 0x11: /* BUSACK */ { + /* Unused bits return prefetched bus data (Time Killers) */ unsigned int data = m68k_read_pcrelative_16(REG_PC) & 0xFEFF; if (zstate == 3) { @@ -541,12 +517,13 @@ unsigned int vdp_read_byte(unsigned int address) case 0x04: /* CTRL */ { - return (((vdp_ctrl_r(mcycles_68k) >> 8) & 3) | (m68k_read_pcrelative_8(REG_PC) & 0xFC)); + /* Unused bits return prefetched bus data */ + return (((vdp_68k_ctrl_r(mcycles_68k) >> 8) & 3) | (m68k_read_pcrelative_8(REG_PC) & 0xFC)); } case 0x05: /* CTRL */ { - return (vdp_ctrl_r(mcycles_68k) & 0xFF); + return (vdp_68k_ctrl_r(mcycles_68k) & 0xFF); } case 0x08: /* HVC */ @@ -587,7 +564,8 @@ unsigned int vdp_read_word(unsigned int address) case 0x04: /* CTRL */ { - return ((vdp_ctrl_r(mcycles_68k) & 0x3FF) | (m68k_read_pcrelative_16(REG_PC) & 0xFC00)); + /* Unused bits return prefetched bus data */ + return ((vdp_68k_ctrl_r(mcycles_68k) & 0x3FF) | (m68k_read_pcrelative_16(REG_PC) & 0xFC00)); } case 0x08: /* HVC */ diff --git a/source/mem68k.h b/source/mem68k.h index 329f620..40844e5 100644 --- a/source/mem68k.h +++ b/source/mem68k.h @@ -1,23 +1,39 @@ /*************************************************************************************** * Genesis Plus - * 68k bus controller + * 68k bus handlers * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -36,12 +52,6 @@ extern unsigned int m68k_lockup_r_16(unsigned int address); extern void m68k_lockup_w_8(unsigned int address, unsigned int data); extern void m68k_lockup_w_16(unsigned int address, unsigned int data); -/* eeprom */ -extern unsigned int eeprom_read_byte(unsigned int address); -extern unsigned int eeprom_read_word(unsigned int address); -extern void eeprom_write_byte(unsigned int address, unsigned int data); -extern void eeprom_write_word(unsigned int address, unsigned int data); - /* Z80 bus */ extern unsigned int z80_read_byte(unsigned int address); extern unsigned int z80_read_word(unsigned int address); diff --git a/source/membnk.c b/source/membnk.c index 952548f..2521601 100644 --- a/source/membnk.c +++ b/source/membnk.c @@ -3,23 +3,40 @@ * Z80 bank access to 68k bus * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ + #include "shared.h" /* @@ -221,12 +238,12 @@ unsigned int zbank_read_vdp(unsigned int address) case 0x04: /* CTRL */ { - return (((vdp_ctrl_r(mcycles_z80) >> 8) & 3) | 0xFC); + return (((vdp_68k_ctrl_r(mcycles_z80) >> 8) & 3) | 0xFC); } case 0x05: /* CTRL */ { - return (vdp_ctrl_r(mcycles_z80) & 0xFF); + return (vdp_68k_ctrl_r(mcycles_z80) & 0xFF); } case 0x08: /* HVC */ diff --git a/source/membnk.h b/source/membnk.h index af46fc9..6665702 100644 --- a/source/membnk.h +++ b/source/membnk.h @@ -3,23 +3,40 @@ * Z80 bank access to 68k bus * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ + #ifndef _MEMBNK_H_ #define _MEMBNK_H_ diff --git a/source/memz80.c b/source/memz80.c index 5ad5041..cfca9f0 100644 --- a/source/memz80.c +++ b/source/memz80.c @@ -1,27 +1,47 @@ /*************************************************************************************** * Genesis Plus - * Z80 bus controller (MD & MS compatibility modes) + * Z80 bus handlers (Genesis & Master System modes) + * + * Support for SG-1000, Mark-III, Master System, Game Gear & Mega Drive ports access * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ + #include "shared.h" + /*--------------------------------------------------------------------------*/ /* Handlers for access to unused addresses and those which make the */ /* machine lock up. */ @@ -72,7 +92,7 @@ static inline unsigned char z80_lockup_r(unsigned int address) /* Z80 Memory handlers (Genesis mode) */ /*--------------------------------------------------------------------------*/ -unsigned char z80_md_memory_r(unsigned int address) +unsigned char z80_memory_r(unsigned int address) { switch((address >> 13) & 7) { @@ -110,7 +130,7 @@ unsigned char z80_md_memory_r(unsigned int address) } -void z80_md_memory_w(unsigned int address, unsigned char data) +void z80_memory_w(unsigned int address, unsigned char data) { switch((address >> 13) & 7) { @@ -166,31 +186,26 @@ void z80_md_memory_w(unsigned int address, unsigned char data) } } - /*--------------------------------------------------------------------------*/ -/* Z80 Memory handlers (Master System mode) */ +/* Unused Port handlers */ +/* */ +/* Ports are unused when not in Mark III compatibility mode. */ +/* */ +/* Genesis games that access ports anyway: */ +/* Thunder Force IV reads port $BF in it's interrupt handler. */ +/* */ /*--------------------------------------------------------------------------*/ -unsigned char z80_sms_memory_r(unsigned int address) -{ - return z80_readmap[(address) >> 10][(address) & 0x03FF]; -} - -/*--------------------------------------------------------------------------*/ -/* Z80 Port handlers */ -/*--------------------------------------------------------------------------*/ -/* - Ports are unused when not in Mark III compatibility mode. - - Genesis games that access ports anyway: - Thunder Force IV reads port $BF in it's interrupt handler. -*/ - unsigned char z80_unused_port_r(unsigned int port) { #if LOGERROR error("Z80 unused read from port %04X (%x)\n", port, Z80.pc.w.l); #endif + if (system_hw == SYSTEM_SMS) + { + unsigned int address = (Z80.pc.w.l - 1) & 0xFFFF; + return z80_readmap[address >> 10][address & 0x3FF]; + } return 0xFF; } @@ -201,13 +216,17 @@ void z80_unused_port_w(unsigned int port, unsigned char data) #endif } -void z80_sms_port_w(unsigned int port, unsigned char data) +/*--------------------------------------------------------------------------*/ +/* MegaDrive / Genesis port handlers (Master System compatibility mode) */ +/*--------------------------------------------------------------------------*/ + +void z80_md_port_w(unsigned int port, unsigned char data) { switch (port & 0xC1) { case 0x01: { - io_z80_write(data); + io_z80_write(1, data, mcycles_z80 + PBC_CYCLE_OFFSET); return; } @@ -232,28 +251,9 @@ void z80_sms_port_w(unsigned int port, unsigned char data) default: { - if ((port & 0xFF) == 0x3E) - { - /* Memory Control Register */ - /* NB: this register does not exist on MD hardware but is partially emulated to support BIOS ROM image files */ - if (data & 0x40) - { - /* Assume only BIOS would disable Cartridge ROM */ - if (data & 0x08) - { - /* BIOS ROM disabled */ - sms_cart_switch(0); - } - else - { - /* BIOS ROM enabled */ - sms_cart_switch(1); - } - } - return; - } + port &= 0xFF; - if ((port >= 0xF0) && (config.ym2413_enabled)) + if ((port >= 0xF0) && (config.ym2413 & 1)) { fm_write(mcycles_z80, port&3, data); return; @@ -265,10 +265,127 @@ void z80_sms_port_w(unsigned int port, unsigned char data) } } -unsigned char z80_sms_port_r(unsigned int port) +unsigned char z80_md_port_r(unsigned int port) { switch (port & 0xC1) { + case 0x40: + { + return ((vdp_hvc_r(mcycles_z80 - 15) >> 8) & 0xFF); + } + + case 0x41: + { + return (vdp_hvc_r(mcycles_z80 - 15) & 0xFF); + } + + case 0x80: + { + return vdp_z80_data_r(); + } + + case 0x81: + { + return vdp_z80_ctrl_r(mcycles_z80); + } + + default: + { + port &= 0xFF; + + if ((port == 0xC0) || (port == 0xC1) || (port == 0xDC) || (port == 0xDD)) + { + return io_z80_read(port & 1); + } + + /* read FM chip if enabled */ + if ((port >= 0xF0) && (config.ym2413 & 1)) + { + return YM2413Read(port & 3); + } + + return z80_unused_port_r(port); + } + } +} + + +/*--------------------------------------------------------------------------*/ +/* Game Gear port handlers */ +/*--------------------------------------------------------------------------*/ + +void z80_gg_port_w(unsigned int port, unsigned char data) +{ + switch(port & 0xC1) + { + case 0x00: + case 0x01: + { + port &= 0xFF; + + if (port < 0x07) + { + if (system_hw == SYSTEM_GG) + { + io_gg_write(port, data); + return; + } + + z80_unused_port_w(port & 0xFF, data); + return; + } + + io_z80_write(port & 1, data, mcycles_z80 + SMS_CYCLE_OFFSET); + return; + } + + case 0x40: + case 0x41: + { + psg_write(mcycles_z80, data); + return; + } + + case 0x80: + { + vdp_z80_data_w(data); + return; + } + + case 0x81: + { + vdp_sms_ctrl_w(data); + return; + } + + default: + { + z80_unused_port_w(port & 0xFF, data); + return; + } + } +} + +unsigned char z80_gg_port_r(unsigned int port) +{ + switch(port & 0xC1) + { + case 0x00: + case 0x01: + { + port &= 0xFF; + + if (port < 0x07) + { + if (system_hw == SYSTEM_GG) + { + return io_gg_read(port); + } + } + + return z80_unused_port_r(port); + } + case 0x40: { return ((vdp_hvc_r(mcycles_z80) >> 8) & 0xFF); @@ -286,23 +403,281 @@ unsigned char z80_sms_port_r(unsigned int port) case 0x81: { - return (vdp_ctrl_r(mcycles_z80) & 0xFF); + return vdp_z80_ctrl_r(mcycles_z80); } default: { port &= 0xFF; - if ((port == 0xC0) || (port == 0xC1) || (port == 0xDC) || (port == 0xDD) || (port == 0xDE) || (port == 0xDF)) + if ((port == 0xC0) || (port == 0xC1) || (port == 0xDC) || (port == 0xDD)) { return io_z80_read(port & 1); } - if ((port >= 0xF0) && (config.ym2413_enabled)) - { - return YM2413Read(port & 3); - } - + return z80_unused_port_r(port); + } + } +} + + +/*--------------------------------------------------------------------------*/ +/* Master System port handlers */ +/*--------------------------------------------------------------------------*/ + +void z80_ms_port_w(unsigned int port, unsigned char data) +{ + switch (port & 0xC1) + { + case 0x00: + case 0x01: + { + io_z80_write(port & 1, data, mcycles_z80 + SMS_CYCLE_OFFSET); + return; + } + + case 0x40: + case 0x41: + { + psg_write(mcycles_z80, data); + return; + } + + case 0x80: + { + vdp_z80_data_w(data); + return; + } + + case 0x81: + { + vdp_sms_ctrl_w(data); + return; + } + + default: + { + if (!(port & 4) && (config.ym2413 & 1)) + { + fm_write(mcycles_z80, port & 3, data); + return; + } + + z80_unused_port_w(port & 0xFF, data); + return; + } + } +} + +unsigned char z80_ms_port_r(unsigned int port) +{ + switch (port & 0xC1) + { + case 0x00: + case 0x01: + { + return z80_unused_port_r(port & 0xFF); + } + + case 0x40: + { + return ((vdp_hvc_r(mcycles_z80) >> 8) & 0xFF); + } + + case 0x41: + { + return (vdp_hvc_r(mcycles_z80) & 0xFF); + } + + case 0x80: + { + return vdp_z80_data_r(); + } + + case 0x81: + { + return vdp_z80_ctrl_r(mcycles_z80); + } + + default: + { + /* read FM chip if enabled */ + if (!(port & 4) && (config.ym2413 & 1)) + { + /* check if I/O ports are disabled */ + if (io_reg[0x0E] & 0x04) + { + return YM2413Read(port & 3); + } + else + { + return YM2413Read(port & 3) & io_z80_read(port & 1); + } + } + + /* check if I/O ports are enabled */ + if (!(io_reg[0x0E] & 0x04)) + { + return io_z80_read(port & 1); + } + + return z80_unused_port_r(port & 0xFF); + } + } +} + + +/*--------------------------------------------------------------------------*/ +/* Mark III port handlers */ +/*--------------------------------------------------------------------------*/ + +void z80_m3_port_w(unsigned int port, unsigned char data) +{ + switch (port & 0xC1) + { + case 0x00: + case 0x01: + { + z80_unused_port_w(port, data); + return; + } + + case 0x40: + case 0x41: + { + psg_write(mcycles_z80, data); + return; + } + + case 0x80: + { + vdp_z80_data_w(data); + return; + } + + case 0x81: + { + vdp_sms_ctrl_w(data); + return; + } + + default: + { + if (!(port & 4) && (config.ym2413 & 1)) + { + fm_write(mcycles_z80, port & 3, data); + return; + } + + z80_unused_port_w(port & 0xFF, data); + return; + } + } +} + +unsigned char z80_m3_port_r(unsigned int port) +{ + switch (port & 0xC1) + { + case 0x00: + case 0x01: + { + return z80_unused_port_r(port & 0xFF); + } + + case 0x40: + { + return ((vdp_hvc_r(mcycles_z80) >> 8) & 0xFF); + } + + case 0x41: + { + return (vdp_hvc_r(mcycles_z80) & 0xFF); + } + + case 0x80: + { + return vdp_z80_data_r(); + } + + case 0x81: + { + return vdp_z80_ctrl_r(mcycles_z80); + } + + default: + { + /* read FM chip if enabled */ + if (!(port & 4) && (config.ym2413 & 1)) + { + /* I/O ports are automatically disabled */ + return YM2413Read(port & 3); + } + + /* read I/O ports */ + return io_z80_read(port & 1); + } + } +} + + +/*--------------------------------------------------------------------------*/ +/* SG-1000 port handlers */ +/*--------------------------------------------------------------------------*/ + +void z80_sg_port_w(unsigned int port, unsigned char data) +{ + switch(port & 0xC1) + { + case 0x40: + case 0x41: + { + psg_write(mcycles_z80, data); + return; + } + + case 0x80: + { + vdp_z80_data_w(data); + return; + } + + case 0x81: + { + vdp_tms_ctrl_w(data); + return; + } + + default: + { + z80_unused_port_w(port & 0xFF, data); + return; + } + } +} + +unsigned char z80_sg_port_r(unsigned int port) +{ + switch (port & 0xC1) + { + case 0x80: + { + return vdp_z80_data_r(); + } + + case 0x81: + { + return vdp_z80_ctrl_r(mcycles_z80); + } + + case 0xC0: + case 0xC1: + { + return io_z80_read(port & 1); + } + + default: + { return z80_unused_port_r(port); } } diff --git a/source/memz80.h b/source/memz80.h index 2abab66..27207f3 100644 --- a/source/memz80.h +++ b/source/memz80.h @@ -1,35 +1,60 @@ /*************************************************************************************** * Genesis Plus - * Z80 bus controller (MD & MS compatibility mode) + * Z80 bus handlers (Genesis & Master System modes) + * + * Support for SG-1000, Mark-III, Master System, Game Gear & Mega Drive ports access * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ + #ifndef _MEMZ80_H_ #define _MEMZ80_H_ -extern unsigned char z80_md_memory_r(unsigned int address); -extern void z80_md_memory_w(unsigned int address, unsigned char data); -extern unsigned char z80_sms_memory_r(unsigned int address); - +extern unsigned char z80_memory_r(unsigned int address); +extern void z80_memory_w(unsigned int address, unsigned char data); extern unsigned char z80_unused_port_r(unsigned int port); extern void z80_unused_port_w(unsigned int port, unsigned char data); -extern unsigned char z80_sms_port_r(unsigned int port); -extern void z80_sms_port_w(unsigned int port, unsigned char data); +extern unsigned char z80_md_port_r(unsigned int port); +extern void z80_md_port_w(unsigned int port, unsigned char data); +extern unsigned char z80_gg_port_r(unsigned int port); +extern void z80_gg_port_w(unsigned int port, unsigned char data); +extern unsigned char z80_ms_port_r(unsigned int port); +extern void z80_ms_port_w(unsigned int port, unsigned char data); +extern unsigned char z80_m3_port_r(unsigned int port); +extern void z80_m3_port_w(unsigned int port, unsigned char data); +extern unsigned char z80_sg_port_r(unsigned int port); +extern void z80_sg_port_w(unsigned int port, unsigned char data); #endif /* _MEMZ80_H_ */ diff --git a/source/shared.h b/source/shared.h index 58a55cb..5171f58 100644 --- a/source/shared.h +++ b/source/shared.h @@ -26,7 +26,8 @@ #include "loadrom.h" #include "sms_cart.h" #include "md_cart.h" -#include "eeprom.h" +#include "md_eeprom.h" +#include "gg_eeprom.h" #include "sram.h" #include "ggenie.h" #include "areplay.h" diff --git a/source/sound/Fir_Resampler.c b/source/sound/Fir_Resampler.c index 85aef32..e11cfb9 100644 --- a/source/sound/Fir_Resampler.c +++ b/source/sound/Fir_Resampler.c @@ -1,6 +1,19 @@ +/* Finite impulse response (FIR) resampler with adjustable FIR size */ + /* Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ -/* Copyright (C) 2004-2006 Shay Green. */ -/* C Conversion by Eke-Eke for use in Genesis Plus (2009). */ + +/* Copyright (C) 2004-2006 Shay Green. This module 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.1 of the License, or (at your option) any later version. This +module 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 module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +/* C Conversion by Eke-Eke for use in Genesis Plus GX (2009). */ #include "Fir_Resampler.h" #include "shared.h" @@ -34,7 +47,7 @@ static void gen_sinc(double rolloff, int width, double offset, double spacing, d double angle = (count / 2 - 1 + offset) * -fstep; - while ( count-- ) + do { *out++ = 0; w = angle * to_w; @@ -51,6 +64,7 @@ static void gen_sinc(double rolloff, int width, double offset, double spacing, d } angle += fstep; } + while(--count); } /*static int available( long input_count ) @@ -149,10 +163,6 @@ double Fir_Resampler_time_ratio( double new_factor, double rolloff ) double pos = 0.0; res = -1; -#ifdef NGC - u32 level = IRQ_Disable(); -#endif - for ( r = 1; r <= MAX_RES; r++ ) { pos += ratio; @@ -195,10 +205,6 @@ double Fir_Resampler_time_ratio( double new_factor, double rolloff ) } } -#ifdef NGC - IRQ_Restore(level); -#endif - Fir_Resampler_clear(); return ratio; diff --git a/source/sound/Fir_Resampler.h b/source/sound/Fir_Resampler.h index a4f0c58..959716f 100644 --- a/source/sound/Fir_Resampler.h +++ b/source/sound/Fir_Resampler.h @@ -1,6 +1,20 @@ /* Finite impulse response (FIR) resampler with adjustable FIR size */ -/* Game_Music_Emu 0.5.2 */ +/* Game_Music_Emu 0.5.2. http://www.slack.net/~ant/ */ + +/* Copyright (C) 2004-2006 Shay Green. This module 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.1 of the License, or (at your option) any later version. This +module 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 module; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + +/* C Conversion by Eke-Eke for use in Genesis Plus GX (2009). */ + #ifndef FIR_RESAMPLER_H #define FIR_RESAMPLER_H diff --git a/source/sound/sn76489.c b/source/sound/sn76489.c index 85bfc7e..f5158ef 100644 --- a/source/sound/sn76489.c +++ b/source/sound/sn76489.c @@ -1,4 +1,4 @@ -/* +/* SN76489 emulation by Maxim in 2001 and 2002 converted from my original Delphi implementation @@ -47,7 +47,7 @@ /* SN76489 clone in Sega's VDP chips (315-5124, 315-5246, 315-5313, Game Gear) */ #define FB_SEGAVDP 0x0009 #define SRW_SEGAVDP 16 - + typedef struct { /* Configuration */ @@ -68,13 +68,12 @@ typedef struct int chan_amp[4]; /* current channel amplitudes in delta buffers */ } SN76489_Context; -static const int PSGVolumeValues[16] = { +static const uint16 PSGVolumeValues[16] = +{ /* These values are taken from a real SMS2's output */ /*{892,892,892,760,623,497,404,323,257,198,159,123,96,75,60,0}, */ - /* I can't remember why 892... :P some scaling I did at some point */ - + /* I can't remember why 892... :P some scaling I did at some point */ /* these values are true volumes for 2dB drops at each step (multiply previous by 10^-0.1) */ - 1516,1205,957,760,603,479,381,303,240,191,152,120,96,76,60,0 }; @@ -101,27 +100,27 @@ void SN76489_Reset() /* Initialise PSG state */ SN76489.Registers[2*i] = 1; /* tone freq=1 */ SN76489.Registers[2*i+1] = 0xf; /* vol=off */ - - /* Set counters to 0 */ + + /* Set counters to 0 */ SN76489.ToneFreqVals[i] = 0; - - /* Set flip-flops to 1 */ + + /* Set flip-flops to 1 */ SN76489.ToneFreqPos[i] = 1; - - /* Clear channels output */ + + /* Clear channels output */ SN76489.Channels[i] = 0; - - /* Clear current amplitudes in delta buffer */ + + /* Clear current amplitudes in delta buffer */ SN76489.chan_amp[i] = 0; } - + SN76489.LatchedRegister=0; - + /* Initialise noise generator */ SN76489.NoiseShiftRegister=NoiseInitialState; SN76489.NoiseFreq = 0x10; SN76489.BoostNoise = config.psgBoostNoise; - + /* Clear Blip delta buffer */ if (blip) blip_clear(blip); } @@ -140,7 +139,6 @@ void SN76489_BoostNoise(int boost) void SN76489_SetContext(uint8 *data) { - memcpy(&SN76489, data, sizeof(SN76489_Context)); } @@ -195,7 +193,7 @@ void SN76489_Write(int data) SN76489.Channels[LatchedRegister>>1] = PSGVolumeValues[data&0x0f]; break; - case 6: /* Noise */ + case 6: /* Noise control */ SN76489.Registers[6] = data & 0x0f; SN76489.NoiseShiftRegister = NoiseInitialState; /* reset shift register */ SN76489.NoiseFreq = 0x10 << (data&0x3); /* set noise signal generator frequency */ @@ -232,7 +230,6 @@ static void UpdateNoiseAmplitude(int time) /* Runs tone channel for clock_length clocks */ static void RunTone(int i, int clock_length) - { int time; @@ -264,7 +261,6 @@ static void RunTone(int i, int clock_length) /* Runs noise channel for clock_length clocks */ static void RunNoise(int clock_length) - { int time; @@ -332,4 +328,4 @@ void SN76489_Update(INT16 *buffer, int length) /* Read samples into output buffer */ blip_end_frame(blip, clock_length); blip_read_samples(blip, buffer, length, 0); -} +} \ No newline at end of file diff --git a/source/sound/sn76489.h b/source/sound/sn76489.h index 0c981bd..55dad53 100644 --- a/source/sound/sn76489.h +++ b/source/sound/sn76489.h @@ -19,5 +19,4 @@ extern void SN76489_Write(int data); extern void SN76489_Update(INT16 *buffer, int length); extern void SN76489_BoostNoise(int boost); -#endif /* _SN76489_H_ */ - +#endif /* _SN76489_H_ */ \ No newline at end of file diff --git a/source/sound/sound.c b/source/sound/sound.c index 598b377..2b06ece 100644 --- a/source/sound/sound.c +++ b/source/sound/sound.c @@ -1,24 +1,40 @@ /*************************************************************************************** * Genesis Plus + * Sound Hardware * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * - * Sound Hardware ****************************************************************************************/ #include "shared.h" @@ -138,7 +154,7 @@ void sound_init(void) /* By default, both chips are running at the output frequency. */ SN76489_Init(mclk/15.0,snd.sample_rate); - if (system_hw != SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { /* YM2612 */ YM2612Init(mclk/7.0,snd.sample_rate); @@ -192,7 +208,7 @@ void sound_restore() uint8 *ptr, *temp; /* save YM context */ - if (system_hw != SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { size = YM2612GetContextSize(); ptr = YM2612GetContextPtr(); @@ -214,7 +230,7 @@ void sound_restore() /* restore YM context */ if (temp) { - if (system_hw != SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { YM2612Restore(temp); } @@ -230,7 +246,7 @@ int sound_context_save(uint8 *state) { int bufferptr = 0; - if (system_hw != SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { bufferptr = YM2612SaveContext(state); } @@ -250,7 +266,7 @@ int sound_context_load(uint8 *state, char *version) { int bufferptr = 0; - if ((system_hw != SYSTEM_PBC) || (version[15] == 0x30)) + if (((system_hw & SYSTEM_PBC) == SYSTEM_MD) || ((version[13] == 0x35) && (version[15] == 0x30))) { bufferptr = YM2612LoadContext(state); } diff --git a/source/sound/sound.h b/source/sound/sound.h index 125b0ee..719edf5 100644 --- a/source/sound/sound.h +++ b/source/sound/sound.h @@ -1,24 +1,40 @@ /*************************************************************************************** * Genesis Plus + * Sound Hardware * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007,2008,2009), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * - * Sound Hardware ****************************************************************************************/ #ifndef _SOUND_H_ diff --git a/source/sound/ym2413.c b/source/sound/ym2413.c index b310024..457de82 100644 --- a/source/sound/ym2413.c +++ b/source/sound/ym2413.c @@ -25,7 +25,7 @@ to do: */ -/** EkeEke (2011): removed multiple chips support and cleaned code for Genesis Plus GX **/ +/** EkeEke (2011): removed multiple chips support, cleaned code & added FM board interface for Genesis Plus GX **/ #include @@ -1016,10 +1016,6 @@ static int init_tables(void) signed int n; double o,m; -#ifdef NGC - u32 level = IRQ_Disable(); -#endif - for (x=0; x>0)&1 ); } - /* Melody (MO) & Rythm (RO) outputs mixing & amplification */ - out = (output[0] + (output[1] * 2)) * 2; + /* Melody (MO) & Rythm (RO) outputs mixing & amplification (latched bit controls FM output) */ + out = (output[0] + (output[1] * 2)) * 2 * ym2413.status; /* Store to stereo sound buffer */ *buffer++ = out; diff --git a/source/sound/ym2612.c b/source/sound/ym2612.c index 6211882..e417fb2 100644 --- a/source/sound/ym2612.c +++ b/source/sound/ym2612.c @@ -1066,142 +1066,158 @@ INLINE void advance_lfo() } -INLINE void advance_eg_channel(FM_SLOT *SLOT) +INLINE void advance_eg_channels(void) { - unsigned int i = 4; /* four operators per channel */ + unsigned int eg_cnt = ym2612.OPN.eg_cnt; + unsigned int i = 0; + unsigned int j; + FM_SLOT *SLOT; do { - switch(SLOT->state) + SLOT = &ym2612.CH[i].SLOT[SLOT1]; + j = 4; /* four operators per channel */ + do { - case EG_ATT: /* attack phase */ - if (!(ym2612.OPN.eg_cnt & ((1<eg_sh_ar)-1))) + switch(SLOT->state) + { + case EG_ATT: /* attack phase */ { - /* update attenuation level */ - SLOT->volume += (~SLOT->volume * (eg_inc[SLOT->eg_sel_ar + ((ym2612.OPN.eg_cnt>>SLOT->eg_sh_ar)&7)]))>>4; - - /* check phase transition*/ - if (SLOT->volume <= MIN_ATT_INDEX) - { - SLOT->volume = MIN_ATT_INDEX; - SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC; /* special case where SL=0 */ - } - - /* recalculate EG output */ - if ((SLOT->ssg&0x08) && (SLOT->ssgn ^ (SLOT->ssg&0x04))) /* SSG-EG Output Inversion */ - SLOT->vol_out = ((UINT32)(0x200 - SLOT->volume) & MAX_ATT_INDEX) + SLOT->tl; - else - SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; - } - break; - - case EG_DEC: /* decay phase */ - if (!(ym2612.OPN.eg_cnt & ((1<eg_sh_d1r)-1))) - { - /* SSG EG type */ - if (SLOT->ssg&0x08) + if (!(eg_cnt & ((1<eg_sh_ar)-1))) { /* update attenuation level */ - if (SLOT->volume < 0x200) + SLOT->volume += (~SLOT->volume * (eg_inc[SLOT->eg_sel_ar + ((eg_cnt>>SLOT->eg_sh_ar)&7)]))>>4; + + /* check phase transition*/ + if (SLOT->volume <= MIN_ATT_INDEX) { - SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d1r + ((ym2612.OPN.eg_cnt>>SLOT->eg_sh_d1r)&7)]; + SLOT->volume = MIN_ATT_INDEX; + SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC; /* special case where SL=0 */ + } + + /* recalculate EG output */ + if ((SLOT->ssg&0x08) && (SLOT->ssgn ^ (SLOT->ssg&0x04))) /* SSG-EG Output Inversion */ + SLOT->vol_out = ((UINT32)(0x200 - SLOT->volume) & MAX_ATT_INDEX) + SLOT->tl; + else + SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; + } + break; + } + + case EG_DEC: /* decay phase */ + { + if (!(eg_cnt & ((1<eg_sh_d1r)-1))) + { + /* SSG EG type */ + if (SLOT->ssg&0x08) + { + /* update attenuation level */ + if (SLOT->volume < 0x200) + { + SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d1r + ((eg_cnt>>SLOT->eg_sh_d1r)&7)]; + + /* recalculate EG output */ + if (SLOT->ssgn ^ (SLOT->ssg&0x04)) /* SSG-EG Output Inversion */ + SLOT->vol_out = ((UINT32)(0x200 - SLOT->volume) & MAX_ATT_INDEX) + SLOT->tl; + else + SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; + } + } + else + { + /* update attenuation level */ + SLOT->volume += eg_inc[SLOT->eg_sel_d1r + ((eg_cnt>>SLOT->eg_sh_d1r)&7)]; /* recalculate EG output */ - if (SLOT->ssgn ^ (SLOT->ssg&0x04)) /* SSG-EG Output Inversion */ - SLOT->vol_out = ((UINT32)(0x200 - SLOT->volume) & MAX_ATT_INDEX) + SLOT->tl; - else - SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; + SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; + } + + /* check phase transition*/ + if (SLOT->volume >= (INT32)(SLOT->sl)) + SLOT->state = EG_SUS; + } + break; + } + + case EG_SUS: /* sustain phase */ + { + if (!(eg_cnt & ((1<eg_sh_d2r)-1))) + { + /* SSG EG type */ + if (SLOT->ssg&0x08) + { + /* update attenuation level */ + if (SLOT->volume < 0x200) + { + SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d2r + ((eg_cnt>>SLOT->eg_sh_d2r)&7)]; + + /* recalculate EG output */ + if (SLOT->ssgn ^ (SLOT->ssg&0x04)) /* SSG-EG Output Inversion */ + SLOT->vol_out = ((UINT32)(0x200 - SLOT->volume) & MAX_ATT_INDEX) + SLOT->tl; + else + SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; + } + } + else + { + /* update attenuation level */ + SLOT->volume += eg_inc[SLOT->eg_sel_d2r + ((eg_cnt>>SLOT->eg_sh_d2r)&7)]; + + /* check phase transition*/ + if ( SLOT->volume >= MAX_ATT_INDEX ) + SLOT->volume = MAX_ATT_INDEX; + /* do not change SLOT->state (verified on real chip) */ + + /* recalculate EG output */ + SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; } } - else + break; + } + + case EG_REL: /* release phase */ + { + if (!(eg_cnt & ((1<eg_sh_rr)-1))) { - /* update attenuation level */ - SLOT->volume += eg_inc[SLOT->eg_sel_d1r + ((ym2612.OPN.eg_cnt>>SLOT->eg_sh_d1r)&7)]; + /* SSG EG type */ + if (SLOT->ssg&0x08) + { + /* update attenuation level */ + if (SLOT->volume < 0x200) + SLOT->volume += 4 * eg_inc[SLOT->eg_sel_rr + ((eg_cnt>>SLOT->eg_sh_rr)&7)]; + + /* check phase transition */ + if (SLOT->volume >= 0x200) + { + SLOT->volume = MAX_ATT_INDEX; + SLOT->state = EG_OFF; + } + } + else + { + /* update attenuation level */ + SLOT->volume += eg_inc[SLOT->eg_sel_rr + ((eg_cnt>>SLOT->eg_sh_rr)&7)]; + + /* check phase transition*/ + if (SLOT->volume >= MAX_ATT_INDEX) + { + SLOT->volume = MAX_ATT_INDEX; + SLOT->state = EG_OFF; + } + } /* recalculate EG output */ SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; - } - /* check phase transition*/ - if (SLOT->volume >= (INT32)(SLOT->sl)) - SLOT->state = EG_SUS; + } + break; } - break; - - case EG_SUS: /* sustain phase */ - if (!(ym2612.OPN.eg_cnt & ((1<eg_sh_d2r)-1))) - { - /* SSG EG type */ - if (SLOT->ssg&0x08) - { - /* update attenuation level */ - if (SLOT->volume < 0x200) - { - SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d2r + ((ym2612.OPN.eg_cnt>>SLOT->eg_sh_d2r)&7)]; - - /* recalculate EG output */ - if (SLOT->ssgn ^ (SLOT->ssg&0x04)) /* SSG-EG Output Inversion */ - SLOT->vol_out = ((UINT32)(0x200 - SLOT->volume) & MAX_ATT_INDEX) + SLOT->tl; - else - SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; - } - } - else - { - /* update attenuation level */ - SLOT->volume += eg_inc[SLOT->eg_sel_d2r + ((ym2612.OPN.eg_cnt>>SLOT->eg_sh_d2r)&7)]; - - /* check phase transition*/ - if ( SLOT->volume >= MAX_ATT_INDEX ) - SLOT->volume = MAX_ATT_INDEX; - /* do not change SLOT->state (verified on real chip) */ - - /* recalculate EG output */ - SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; - } - } - break; - - case EG_REL: /* release phase */ - if (!(ym2612.OPN.eg_cnt & ((1<eg_sh_rr)-1))) - { - /* SSG EG type */ - if (SLOT->ssg&0x08) - { - /* update attenuation level */ - if (SLOT->volume < 0x200) - SLOT->volume += 4 * eg_inc[SLOT->eg_sel_rr + ((ym2612.OPN.eg_cnt>>SLOT->eg_sh_rr)&7)]; - - /* check phase transition */ - if (SLOT->volume >= 0x200) - { - SLOT->volume = MAX_ATT_INDEX; - SLOT->state = EG_OFF; - } - } - else - { - /* update attenuation level */ - SLOT->volume += eg_inc[SLOT->eg_sel_rr + ((ym2612.OPN.eg_cnt>>SLOT->eg_sh_rr)&7)]; - - /* check phase transition*/ - if (SLOT->volume >= MAX_ATT_INDEX) - { - SLOT->volume = MAX_ATT_INDEX; - SLOT->state = EG_OFF; - } - } - - /* recalculate EG output */ - SLOT->vol_out = (UINT32)SLOT->volume + SLOT->tl; - - } - break; - } - - SLOT++; - i--; - } while (i); + } + SLOT++; + j--; + } while (j); + i++; + } while (i < 6); /* 6 channels */ } /* SSG-EG update process */ @@ -1267,21 +1283,20 @@ INLINE void update_ssg_eg_channel(FM_SLOT *SLOT) INLINE void update_phase_lfo_slot(FM_SLOT *SLOT , INT32 pms, UINT32 block_fnum) { - UINT32 fnum_lfo = ((block_fnum & 0x7f0) >> 4) * 32 * 8; - INT32 lfo_fn_table_index_offset = lfo_pm_table[ fnum_lfo + pms + ym2612.OPN.LFO_PM ]; + INT32 lfo_fn_table_index_offset = lfo_pm_table[ (((block_fnum & 0x7f0) >> 4) << 8) + pms + ym2612.OPN.LFO_PM ]; if (lfo_fn_table_index_offset) /* LFO phase modulation active */ { block_fnum = block_fnum*2 + lfo_fn_table_index_offset; UINT8 blk = (block_fnum&0x7000) >> 12; - UINT32 fn = block_fnum & 0xfff; + block_fnum = block_fnum & 0xfff; /* keyscale code */ - int kc = (blk<<2) | opn_fktable[fn >> 8]; + int kc = (blk<<2) | opn_fktable[block_fnum >> 8]; /* (frequency) phase increment counter */ - int fc = (ym2612.OPN.fn_table[fn]>>(7-blk)) + SLOT->DT[kc]; + int fc = (ym2612.OPN.fn_table[block_fnum]>>(7-blk)) + SLOT->DT[kc]; /* (frequency) phase overflow (credits to Nemesis) */ if (fc < 0) fc += ym2612.OPN.fn_max; @@ -1299,21 +1314,20 @@ INLINE void update_phase_lfo_channel(FM_CH *CH) { UINT32 block_fnum = CH->block_fnum; - UINT32 fnum_lfo = ((block_fnum & 0x7f0) >> 4) * 32 * 8; - INT32 lfo_fn_table_index_offset = lfo_pm_table[ fnum_lfo + CH->pms + ym2612.OPN.LFO_PM ]; + INT32 lfo_fn_table_index_offset = lfo_pm_table[ (((block_fnum & 0x7f0) >> 4) << 8) + CH->pms + ym2612.OPN.LFO_PM ]; if (lfo_fn_table_index_offset) /* LFO phase modulation active */ { block_fnum = block_fnum*2 + lfo_fn_table_index_offset; UINT8 blk = (block_fnum&0x7000) >> 12; - UINT32 fn = block_fnum & 0xfff; + block_fnum = block_fnum & 0xfff; /* keyscale code */ - int kc = (blk<<2) | opn_fktable[fn >> 8]; + int kc = (blk<<2) | opn_fktable[block_fnum >> 8]; /* (frequency) phase increment counter */ - int fc = (ym2612.OPN.fn_table[fn]>>(7-blk)); + int fc = (ym2612.OPN.fn_table[block_fnum]>>(7-blk)); /* (frequency) phase overflow (credits to Nemesis) */ int finc = fc + CH->SLOT[SLOT1].DT[kc]; @@ -1344,8 +1358,7 @@ INLINE void update_phase_lfo_channel(FM_CH *CH) /* update phase increment and envelope generator */ INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT , int fc , int kc ) { - int ksr = kc >> SLOT->KSR; - + /* add detune value */ fc += SLOT->DT[kc]; /* (frequency) phase overflow (credits to Nemesis) */ @@ -1354,15 +1367,18 @@ INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT , int fc , int kc ) /* (frequency) phase increment counter */ SLOT->Incr = (fc * SLOT->mul) >> 1; - if( SLOT->ksr != ksr ) + /* ksr */ + kc = kc >> SLOT->KSR; + + if( SLOT->ksr != kc ) { - SLOT->ksr = ksr; + SLOT->ksr = kc; /* recalculate envelope generator rates */ - if ((SLOT->ar + SLOT->ksr) < (32+62)) + if ((SLOT->ar + kc) < (32+62)) { - SLOT->eg_sh_ar = eg_rate_shift [SLOT->ar + SLOT->ksr ]; - SLOT->eg_sel_ar = eg_rate_select[SLOT->ar + SLOT->ksr ]; + SLOT->eg_sh_ar = eg_rate_shift [SLOT->ar + kc ]; + SLOT->eg_sel_ar = eg_rate_select[SLOT->ar + kc ]; } else { @@ -1371,14 +1387,14 @@ INLINE void refresh_fc_eg_slot(FM_SLOT *SLOT , int fc , int kc ) SLOT->eg_sel_ar = 18*RATE_STEPS; } - SLOT->eg_sh_d1r = eg_rate_shift [SLOT->d1r + SLOT->ksr]; - SLOT->eg_sel_d1r= eg_rate_select[SLOT->d1r + SLOT->ksr]; + SLOT->eg_sh_d1r = eg_rate_shift [SLOT->d1r + kc]; + SLOT->eg_sel_d1r= eg_rate_select[SLOT->d1r + kc]; - SLOT->eg_sh_d2r = eg_rate_shift [SLOT->d2r + SLOT->ksr]; - SLOT->eg_sel_d2r= eg_rate_select[SLOT->d2r + SLOT->ksr]; + SLOT->eg_sh_d2r = eg_rate_shift [SLOT->d2r + kc]; + SLOT->eg_sel_d2r= eg_rate_select[SLOT->d2r + kc]; - SLOT->eg_sh_rr = eg_rate_shift [SLOT->rr + SLOT->ksr]; - SLOT->eg_sel_rr = eg_rate_select[SLOT->rr + SLOT->ksr]; + SLOT->eg_sh_rr = eg_rate_shift [SLOT->rr + kc]; + SLOT->eg_sel_rr = eg_rate_select[SLOT->rr + kc]; } } @@ -1400,9 +1416,7 @@ INLINE void refresh_fc_eg_chan(FM_CH *CH ) INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm) { - UINT32 p; - - p = (env<<3) + sin_tab[ ( ((signed int)((phase & ~FREQ_MASK) + (pm<<15))) >> FREQ_SH ) & SIN_MASK ]; + UINT32 p = (env<<3) + sin_tab[ ( ((signed int)((phase & ~FREQ_MASK) + (pm<<15))) >> FREQ_SH ) & SIN_MASK ]; if (p >= TL_TAB_LEN) return 0; @@ -1411,9 +1425,7 @@ INLINE signed int op_calc(UINT32 phase, unsigned int env, signed int pm) INLINE signed int op_calc1(UINT32 phase, unsigned int env, signed int pm) { - UINT32 p; - - p = (env<<3) + sin_tab[ ( ((signed int)((phase & ~FREQ_MASK) + pm )) >> FREQ_SH ) & SIN_MASK ]; + UINT32 p = (env<<3) + sin_tab[ ( ((signed int)((phase & ~FREQ_MASK) + pm )) >> FREQ_SH ) & SIN_MASK ]; if (p >= TL_TAB_LEN) return 0; @@ -1833,10 +1845,6 @@ static void init_tables(void) signed int n; double o,m; -#ifdef NGC - u32 level = IRQ_Disable(); -#endif - /* DAC precision */ unsigned int mask = ~((1 << (14 - config.dac_bits)) - 1); @@ -1898,10 +1906,6 @@ static void init_tables(void) sin_tab[ i ] = n*2 + (m>=0.0? 0: 1 ); } -#ifdef NGC - IRQ_Restore(level); -#endif - /* build LFO PM modulation table */ for(i = 0; i < 8; i++) /* 8 PM depths */ { @@ -1955,10 +1959,11 @@ void YM2612ResetChip(void) ym2612.OPN.eg_timer = 0; ym2612.OPN.eg_cnt = 0; - ym2612.OPN.lfo_timer = 0; - ym2612.OPN.lfo_cnt = 0; - ym2612.OPN.LFO_AM = 0; - ym2612.OPN.LFO_PM = 0; + ym2612.OPN.lfo_timer_overflow = 0; + ym2612.OPN.lfo_timer = 0; + ym2612.OPN.lfo_cnt = 0; + ym2612.OPN.LFO_AM = 0; + ym2612.OPN.LFO_PM = 0; ym2612.OPN.ST.TAC = 0; ym2612.OPN.ST.TBC = 0; @@ -1967,12 +1972,12 @@ void YM2612ResetChip(void) ym2612.dacen = 0; ym2612.dacout = 0; - - OPNWriteMode(0x27,0x30); - OPNWriteMode(0x26,0x00); - OPNWriteMode(0x25,0x00); - OPNWriteMode(0x24,0x00); - OPNWriteMode(0x22,0x00); + + set_timers(0x30); + ym2612.OPN.ST.TB = 0; + ym2612.OPN.ST.TBL = 256 << (TIMER_SH + 4); + ym2612.OPN.ST.TA = 0; + ym2612.OPN.ST.TAL = 1024 << TIMER_SH; reset_channels(&ym2612.CH[0] , 6 ); @@ -2050,8 +2055,12 @@ void YM2612Update(long int *buffer, int length) refresh_fc_eg_chan(&ym2612.CH[0]); refresh_fc_eg_chan(&ym2612.CH[1]); - if (ym2612.OPN.ST.mode & 0xC0) + if (!(ym2612.OPN.ST.mode & 0xC0)) { + refresh_fc_eg_chan(&ym2612.CH[2]); + } + else + { /* 3SLOT MODE (operator order is 0,1,3,2) */ if(ym2612.CH[2].SLOT[SLOT1].Incr==-1) { @@ -2061,7 +2070,6 @@ void YM2612Update(long int *buffer, int length) refresh_fc_eg_slot(&ym2612.CH[2].SLOT[SLOT4] , ym2612.CH[2].fc , ym2612.CH[2].kcode ); } } - else refresh_fc_eg_chan(&ym2612.CH[2]); refresh_fc_eg_chan(&ym2612.CH[3]); refresh_fc_eg_chan(&ym2612.CH[4]); @@ -2092,12 +2100,15 @@ void YM2612Update(long int *buffer, int length) chan_calc(&ym2612.CH[2]); chan_calc(&ym2612.CH[3]); chan_calc(&ym2612.CH[4]); - if (ym2612.dacen) + if (!ym2612.dacen) + { + chan_calc(&ym2612.CH[5]); + } + else { /* DAC Mode */ out_fm[5] = ym2612.dacout; } - else chan_calc(&ym2612.CH[5]); /* advance LFO */ advance_lfo(); @@ -2108,13 +2119,7 @@ void YM2612Update(long int *buffer, int length) { ym2612.OPN.eg_timer -= ym2612.OPN.eg_timer_overflow; ym2612.OPN.eg_cnt++; - - advance_eg_channel(&ym2612.CH[0].SLOT[SLOT1]); - advance_eg_channel(&ym2612.CH[1].SLOT[SLOT1]); - advance_eg_channel(&ym2612.CH[2].SLOT[SLOT1]); - advance_eg_channel(&ym2612.CH[3].SLOT[SLOT1]); - advance_eg_channel(&ym2612.CH[4].SLOT[SLOT1]); - advance_eg_channel(&ym2612.CH[5].SLOT[SLOT1]); + advance_eg_channels(); } /* 14-bit DAC inputs (range is -8192;+8192) */ diff --git a/source/state.c b/source/state.c index d5dff82..1c935ea 100644 --- a/source/state.c +++ b/source/state.c @@ -2,21 +2,37 @@ * Genesis Plus * Savestate support * - * Copyright (C) 2007-2011 Eke-Eke (GCN/Wii port) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -58,11 +74,7 @@ int state_load(unsigned char *buffer) system_reset(); // GENESIS - if (system_hw == SYSTEM_PBC) - { - load_param(work_ram, 0x2000); - } - else + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { load_param(work_ram, sizeof(work_ram)); load_param(zram, sizeof(zram)); @@ -83,30 +95,34 @@ int state_load(unsigned char *buffer) m68k_memory_map[0xa0].write16 = m68k_unused_16_w; } } + else + { + load_param(work_ram, 0x2000); + } /* extended state */ load_param(&mcycles_68k, sizeof(mcycles_68k)); load_param(&mcycles_z80, sizeof(mcycles_z80)); // IO - if (system_hw == SYSTEM_PBC) - { - load_param(&io_reg[0], 1); - } - else + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { load_param(io_reg, sizeof(io_reg)); io_reg[0] = region_code | 0x20 | (config.tmss & 1); } + else + { + load_param(&io_reg[0x0F], 1); + } // VDP - bufferptr += vdp_context_load(&state[bufferptr]); + bufferptr += vdp_context_load(&state[bufferptr], version); // SOUND bufferptr += sound_context_load(&state[bufferptr], version); // 68000 - if (system_hw != SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { uint16 tmp16; uint32 tmp32; @@ -136,14 +152,14 @@ int state_load(unsigned char *buffer) Z80.irq_callback = z80_irq_callback; // Cartridge HW - if (system_hw == SYSTEM_PBC) - { - bufferptr += sms_cart_context_load(&state[bufferptr]); - } - else + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { bufferptr += md_cart_context_load(&state[bufferptr]); } + else + { + bufferptr += sms_cart_context_load(&state[bufferptr]); + } free(state); return 1; @@ -164,28 +180,28 @@ int state_save(unsigned char *buffer) save_param(version, 16); // GENESIS - if (system_hw == SYSTEM_PBC) - { - save_param(work_ram, 0x2000); - } - else + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { save_param(work_ram, sizeof(work_ram)); save_param(zram, sizeof(zram)); save_param(&zstate, sizeof(zstate)); save_param(&zbank, sizeof(zbank)); } + else + { + save_param(work_ram, 0x2000); + } save_param(&mcycles_68k, sizeof(mcycles_68k)); save_param(&mcycles_z80, sizeof(mcycles_z80)); // IO - if (system_hw == SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { - save_param(&io_reg[0], 1); + save_param(io_reg, sizeof(io_reg)); } else { - save_param(io_reg, sizeof(io_reg)); + save_param(&io_reg[0x0F], 1); } // VDP @@ -195,42 +211,42 @@ int state_save(unsigned char *buffer) bufferptr += sound_context_save(&state[bufferptr]); // 68000 - if (system_hw != SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { uint16 tmp16; uint32 tmp32; - tmp32 = m68k_get_reg(NULL, M68K_REG_D0); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D1); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D2); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D3); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D4); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D5); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D6); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_D7); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A0); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A1); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A2); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A3); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A4); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A5); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A6); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_A7); save_param(&tmp32, 4); - tmp32 = m68k_get_reg(NULL, M68K_REG_PC); save_param(&tmp32, 4); - tmp16 = m68k_get_reg(NULL, M68K_REG_SR); save_param(&tmp16, 2); - tmp32 = m68k_get_reg(NULL, M68K_REG_USP); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_D0); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_D1); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_D2); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_D3); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_D4); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_D5); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_D6); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_D7); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_A0); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_A1); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_A2); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_A3); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_A4); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_A5); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_A6); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_A7); save_param(&tmp32, 4); + tmp32 = m68k_get_reg(M68K_REG_PC); save_param(&tmp32, 4); + tmp16 = m68k_get_reg(M68K_REG_SR); save_param(&tmp16, 2); + tmp32 = m68k_get_reg(M68K_REG_USP); save_param(&tmp32, 4); } // Z80 save_param(&Z80, sizeof(Z80_Regs)); // Cartridge HW - if (system_hw == SYSTEM_PBC) + if ((system_hw & SYSTEM_PBC) == SYSTEM_MD) { - bufferptr += sms_cart_context_save(&state[bufferptr]); + bufferptr += md_cart_context_save(&state[bufferptr]); } else { - bufferptr += md_cart_context_save(&state[bufferptr]); + bufferptr += sms_cart_context_save(&state[bufferptr]); } /* compress state file */ diff --git a/source/state.h b/source/state.h index ba43520..f21497f 100644 --- a/source/state.h +++ b/source/state.h @@ -2,21 +2,37 @@ * Genesis Plus * Savestate support * - * Copyright (C) 2007-2011 Eke-Eke (GCN/Wii port) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -24,7 +40,7 @@ #define _STATE_H_ #define STATE_SIZE 0x48100 -#define STATE_VERSION "GENPLUS-GX 1.5.1" +#define STATE_VERSION "GENPLUS-GX 1.6.0" #define load_param(param, size) \ memcpy(param, &state[bufferptr], size); \ diff --git a/source/system.c b/source/system.c index 5753c0c..a8e107e 100644 --- a/source/system.c +++ b/source/system.c @@ -2,22 +2,40 @@ * Genesis Plus * Virtual System emulation * + * Support for Genesis & Master System compatibility modes + * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port -* - * 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. + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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 + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -34,9 +52,9 @@ uint32 mcycles_68k; uint8 system_hw; void (*system_frame)(int do_skip); -static void system_frame_md(int do_skip); +static void system_frame_gen(int do_skip); static void system_frame_sms(int do_skip); -static int pause_b; +static uint8 pause_b; static EQSTATE eq; static int32 llp,rrp; @@ -249,7 +267,22 @@ void system_init(void) vdp_init(); render_init(); sound_init(); - system_frame = (system_hw == SYSTEM_PBC) ? system_frame_sms : system_frame_md; + + switch (system_hw) + { + case SYSTEM_MD: + case SYSTEM_PICO: + { + system_frame = system_frame_gen; + break; + } + + default: + { + system_frame = system_frame_sms; + break; + } + } } /**************************************************************** @@ -259,8 +292,8 @@ void system_reset(void) { gen_reset(1); io_reset(); - vdp_reset(); render_reset(); + vdp_reset(); sound_reset(); audio_reset(); } @@ -271,7 +304,7 @@ void system_shutdown (void) SN76489_Shutdown(); } -static void system_frame_md(int do_skip) +static void system_frame_gen(int do_skip) { /* line counter */ int line = 0; @@ -300,13 +333,18 @@ static void system_frame_md(int do_skip) { bitmap.viewport.changed &= ~2; - /* interlaced mode */ + /* interlaced modes */ int old_interlaced = interlaced; interlaced = (reg[12] & 0x02) >> 1; if (old_interlaced != interlaced) { + /* double resolution mode */ im2_flag = ((reg[12] & 0x06) == 0x06); + + /* reset field status flag */ odd_frame = 1; + + /* video mode has changed */ bitmap.viewport.changed = 5; /* update rendering mode */ @@ -361,7 +399,7 @@ static void system_frame_md(int do_skip) } /* render last line of overscan */ - if (bitmap.viewport.y) + if (bitmap.viewport.y > 0) { blank_line(v_counter, -bitmap.viewport.x, bitmap.viewport.w + 2*bitmap.viewport.x); } @@ -411,7 +449,7 @@ static void system_frame_md(int do_skip) hint_pending = 0x10; if (reg[0] & 0x10) { - m68k_irq_state |= 0x14; + m68k_update_irq(4); } } @@ -480,7 +518,7 @@ static void system_frame_md(int do_skip) hint_pending = 0x10; if (reg[0] & 0x10) { - m68k_irq_state |= 0x14; + m68k_update_irq(4); } } @@ -518,7 +556,7 @@ static void system_frame_md(int do_skip) vint_pending = 0x20; if (reg[1] & 0x20) { - m68k_irq_state = 0x16; + m68k_set_irq(6); } /* assert Z80 interrupt */ @@ -634,101 +672,152 @@ static void system_frame_sms(int do_skip) { bitmap.viewport.changed &= ~2; - /* interlaced mode */ - int old_interlaced = interlaced; - interlaced = (reg[12] & 0x02) >> 1; - if (old_interlaced != interlaced) + if (system_hw & SYSTEM_MD) { - im2_flag = ((reg[12] & 0x06) == 0x06); - odd_frame = 1; - bitmap.viewport.changed = 5; - - /* update rendering mode */ - if (reg[1] & 0x04) + /* interlaced mode */ + int old_interlaced = interlaced; + interlaced = (reg[12] & 0x02) >> 1; + if (old_interlaced != interlaced) { - if (im2_flag) - { - render_bg = (reg[11] & 0x04) ? render_bg_m5_im2_vs : render_bg_m5_im2; - render_obj = render_obj_m5_im2; + im2_flag = ((reg[12] & 0x06) == 0x06); + odd_frame = 1; + bitmap.viewport.changed = 5; - } - else + /* update rendering mode */ + if (reg[1] & 0x04) { - render_bg = (reg[11] & 0x04) ? render_bg_m5_vs : render_bg_m5; - render_obj = render_obj_m5; + if (im2_flag) + { + render_bg = (reg[11] & 0x04) ? render_bg_m5_im2_vs : render_bg_m5_im2; + render_obj = render_obj_m5_im2; + + } + else + { + render_bg = (reg[11] & 0x04) ? render_bg_m5_vs : render_bg_m5; + render_obj = render_obj_m5; + } } } - } - /* active screen height */ - if (reg[1] & 0x04) - { - bitmap.viewport.h = 224 + ((reg[1] & 0x08) << 1); - bitmap.viewport.y = (config.overscan & 1) * ((240 + 48*vdp_pal - bitmap.viewport.h) >> 1); + /* active screen height */ + if (reg[1] & 0x04) + { + bitmap.viewport.h = 224 + ((reg[1] & 0x08) << 1); + bitmap.viewport.y = (config.overscan & 1) * ((240 + 48*vdp_pal - bitmap.viewport.h) >> 1); + } + else + { + bitmap.viewport.h = 192; + bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1); + } + + /* active screen width */ + bitmap.viewport.w = 256 + ((reg[12] & 0x01) << 6); } else { - bitmap.viewport.h = 192; - bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1); - } + /* check for VDP extended modes */ + int mode = (reg[0] & 0x06) | (reg[1] & 0x18); - /* active screen width */ - bitmap.viewport.w = 256 + ((reg[12] & 0x01) << 6); + /* update active height */ + if (mode == 0x0E) + { + bitmap.viewport.h = 240; + } + else if (mode == 0x16) + { + bitmap.viewport.h = 224; + } + else + { + bitmap.viewport.h = 192; + } + + /* update vertical overscan */ + if (config.overscan & 1) + { + bitmap.viewport.y = (240 + 48*vdp_pal - bitmap.viewport.h) >> 1; + } + else + { + if (system_hw == SYSTEM_GG) + { + /* Display area reduced to 160x144 */ + bitmap.viewport.y = (144 - bitmap.viewport.h) / 2; + } + else + { + bitmap.viewport.y = 0; + } + } + } } - /* Detect pause button input */ - if (input.pad[0] & INPUT_START) + /* Detect pause button input (in Game Gear Mode, NMI is not generated) */ + if ((system_hw != SYSTEM_GG) && (system_hw != SYSTEM_SG)) { - /* NMI is edge-triggered */ - if (!pause_b) + if (input.pad[0] & INPUT_START) { - pause_b = 1; - z80_set_nmi_line(ASSERT_LINE); - z80_set_nmi_line(CLEAR_LINE); + /* NMI is edge-triggered */ + if (!pause_b) + { + pause_b = 1; + z80_set_nmi_line(ASSERT_LINE); + z80_set_nmi_line(CLEAR_LINE); + } + } + else + { + pause_b = 0; } - } - else - { - pause_b = 0; } /* 3-D glasses faking: skip rendering of left lens frame */ do_skip |= (work_ram[0x1ffb] & cart.special); - /* clear VBLANK, DMA, FIFO FULL & field flags */ - status &= 0xFEE5; - - /* set FIFO EMPTY flag */ - status |= 0x0200; - - /* even/odd field flag (interlaced modes only) */ - odd_frame ^= 1; - if (interlaced) + /* Mega Drive VDP specific */ + if (system_hw & SYSTEM_MD) { - status |= (odd_frame << 4); + /* clear VBLANK, DMA & field flags */ + status &= 0xE5; + + /* even/odd field flag (interlaced modes only) */ + odd_frame ^= 1; + if (interlaced) + { + status |= (odd_frame << 4); + } + + /* update VDP DMA */ + if (dma_length) + { + vdp_dma_update(0); + } } - /* update VDP DMA */ - if (dma_length) + /* Master System & Game Gear VDP specific */ + if (system_hw < SYSTEM_MD) { - vdp_dma_update(0); + /* Sprites are still processed during vertical borders */ + if (reg[1] & 0x40) + { + render_obj(bitmap.viewport.w); + } } /* render last line of overscan */ - if (bitmap.viewport.y) + if (bitmap.viewport.y > 0) { blank_line(v_counter, -bitmap.viewport.x, bitmap.viewport.w + 2*bitmap.viewport.x); } - /* parse first line of sprites */ - if (reg[1] & 0x40) + /* parse first line of sprites (on Master System VDP, pre-processing still occurs when display is disabled) */ + if ((reg[1] & 0x40) || (system_hw < SYSTEM_MD)) { parse_satb(-1); } - /* latch Horizontal Scroll register (if modified during VBLANK) */ - hscroll = reg[0x08]; - /* run Z80 */ z80_run(MCYCLES_PER_LINE); @@ -741,8 +830,24 @@ static void system_frame_sms(int do_skip) /* Active Display */ do { - /* update V Counter */ - v_counter = line; + /* update VDP DMA (Mega Drive VDP specific) */ + if (dma_length) + { + vdp_dma_update(mcycles_vdp); + } + + /* make sure we didn't already render that line */ + if (v_counter != line) + { + /* update V Counter */ + v_counter = line; + + /* render scanline */ + if (!do_skip) + { + render_line(line); + } + } /* update 6-Buttons & Lightguns */ input_refresh(); @@ -757,9 +862,10 @@ static void system_frame_sms(int do_skip) hint_pending = 0x10; if (reg[0] & 0x10) { - /* IRQ line is latched between instructions, on instruction last cycle */ - /* This means that if Z80 cycle count is exactly a multiple of MCYCLES_PER_LINE, */ - /* interrupt should be triggered AFTER the next instruction. */ + /* cycle-accurate HINT */ + /* IRQ line is latched between instructions, during instruction last cycle. */ + /* This means that if Z80 cycle count is exactly a multiple of MCYCLES_PER_LINE, */ + /* interrupt should be triggered AFTER the next instruction. */ if ((mcycles_z80 % MCYCLES_PER_LINE) == 0) { z80_run(mcycles_z80 + 1); @@ -769,18 +875,6 @@ static void system_frame_sms(int do_skip) } } - /* update VDP DMA */ - if (dma_length) - { - vdp_dma_update(mcycles_vdp); - } - - /* render scanline */ - if (!do_skip) - { - render_line(line); - } - /* run Z80 */ z80_run(mcycles_vdp + MCYCLES_PER_LINE); @@ -792,8 +886,12 @@ static void system_frame_sms(int do_skip) /* end of active display */ v_counter = line; - /* set VBLANK flag */ - status |= 0x08; + /* Mega Drive VDP specific */ + if (system_hw & SYSTEM_MD) + { + /* set VBLANK flag */ + status |= 0x08; + } /* overscan area */ int start = lines_per_frame - bitmap.viewport.y; @@ -820,11 +918,17 @@ static void system_frame_sms(int do_skip) hint_pending = 0x10; if (reg[0] & 0x10) { + /* cycle-accurate HINT */ + if ((mcycles_z80 % MCYCLES_PER_LINE) == 0) + { + z80_run(mcycles_z80 + 1); + } + Z80.irq_state = ASSERT_LINE; } } - /* update VDP DMA */ + /* update VDP DMA (Mega Drive VDP specific) */ if (dma_length) { vdp_dma_update(mcycles_vdp); @@ -836,20 +940,24 @@ static void system_frame_sms(int do_skip) blank_line(line, -bitmap.viewport.x, bitmap.viewport.w + 2*bitmap.viewport.x); } - /* update inputs before VINT (Warriors of Eternal Sun) */ + /* update inputs before VINT */ osd_input_Update(); /* run Z80 until end of line */ z80_run(mcycles_vdp + MCYCLES_PER_LINE); - /* VINT flag */ - status |= 0x80; - - /* V Interrupt */ - vint_pending = 0x20; - if (reg[1] & 0x20) + /* make sure VINT flag was not cleared by last instruction */ + if (v_counter == line) { - Z80.irq_state = ASSERT_LINE; + /* Set VINT flag */ + status |= 0x80; + + /* V Interrupt */ + vint_pending = 0x20; + if (reg[1] & 0x20) + { + Z80.irq_state = ASSERT_LINE; + } } /* update line cycle count */ @@ -867,6 +975,14 @@ static void system_frame_sms(int do_skip) /* update 6-Buttons & Lightguns */ input_refresh(); + /* Master System & Game Gear VDP specific */ + if ((system_hw < SYSTEM_MD) && (line > (lines_per_frame - 16))) + { + /* Sprites are still processed during top border */ + render_obj(bitmap.viewport.w); + parse_satb(line - lines_per_frame); + } + /* render overscan */ if ((line < end) || (line >= start)) { diff --git a/source/system.h b/source/system.h index 4a276e4..10a469f 100644 --- a/source/system.h +++ b/source/system.h @@ -1,47 +1,71 @@ /*************************************************************************************** * Genesis Plus - * Virtual System Emulation + * Virtual System emulation + * + * Support for Genesis & Master System compatibility modes * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ #ifndef _SYSTEM_H_ #define _SYSTEM_H_ -#define SYSTEM_PBC 0x00 -#define SYSTEM_GENESIS 0x01 -#define SYSTEM_MEGADRIVE 0x02 -#define SYSTEM_PICO 0x03 +/* Supported hardware models */ +#define SYSTEM_SG 0x10 +#define SYSTEM_MARKIII 0x11 +#define SYSTEM_SMS 0x20 +#define SYSTEM_SMS2 0x21 +#define SYSTEM_GG 0x40 +#define SYSTEM_GGMS 0x41 +#define SYSTEM_MD 0x80 +#define SYSTEM_PBC 0x81 +#define SYSTEM_PICO 0x82 +/* Number of M-Cycles executed per line */ #define MCYCLES_PER_LINE 3420 -#define Z80_CYCLE_OFFSET 550 /* horizontal timings offset when running in SMS mode */ +/* Horizontal timing offsets when running in Z80 mode */ +#define SMS_CYCLE_OFFSET 520 +#define PBC_CYCLE_OFFSET 550 typedef struct { uint8 *data; /* Bitmap data */ int width; /* Bitmap width */ int height; /* Bitmap height */ - int depth; /* Color depth (8-32 bits) */ - int pitch; /* Width of bitmap in bytes */ - int granularity; /* Size of each pixel in bytes */ - int remap; /* 1= Translate pixel data */ + int pitch; /* Bitmap pitch */ struct { int x; /* X offset of viewport within bitmap */ diff --git a/source/types.h b/source/types.h index 0a6423e..f269088 100644 --- a/source/types.h +++ b/source/types.h @@ -1,21 +1,3 @@ -/* - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald - - 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 -*/ - #undef uint8 #undef uint16 #undef uint32 @@ -26,4 +8,3 @@ #define int8 signed char #define int16 signed short #define int32 signed long int - diff --git a/source/vdp_ctrl.c b/source/vdp_ctrl.c index a797208..63da9d3 100644 --- a/source/vdp_ctrl.c +++ b/source/vdp_ctrl.c @@ -2,22 +2,40 @@ * Genesis Plus * Video Display Processor (68k & Z80 CPU interface) * + * Support for SG-1000, Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP + * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -43,7 +61,6 @@ uint8 vsram[0x80]; /* On-chip vertical scroll RAM (40 x 11-bit) */ uint8 reg[0x20]; /* Internal VDP registers (23 x 8-bit) */ uint8 hint_pending; /* 0= Line interrupt is pending */ uint8 vint_pending; /* 1= Frame interrupt is pending */ -uint8 m68k_irq_state; /* 68K IRQ status */ uint16 status; /* VDP status flags */ uint32 dma_length; /* DMA remaining length */ @@ -61,7 +78,6 @@ uint8 hscroll_mask; /* Horizontal Scrolling line mask */ uint8 playfield_shift; /* Width of planes A, B (in bits) */ uint8 playfield_col_mask; /* Playfield column mask */ uint16 playfield_row_mask; /* Playfield row mask */ -uint16 hscroll; /* Latched horizontal scroll value */ uint16 vscroll; /* Latched vertical scroll value */ uint8 odd_frame; /* 1: odd field, 0: even field */ uint8 im2_flag; /* 1= Interlace mode 2 is being used */ @@ -98,9 +114,12 @@ static uint16 sat_base_mask; /* Base bits of SAT */ static uint16 sat_addr_mask; /* Index bits of SAT */ static uint32 dma_endCycles; /* 68k cycles to DMA end */ static uint32 fifo_latency; /* CPU access latency */ -static int cached_write; /* 2nd part of 32-bit CTRL port write */ +static int cached_write; /* 2nd part of 32-bit CTRL port write (Genesis mode) or LSB of CRAM data (Game Gear mode) */ static uint16 fifo[4]; /* FIFO buffer */ -static uint8 *irq_line; /* Z80 or 68k interrupt lines */ + + /* set Z80 or 68k interrupt lines */ +static void (*set_irq_line)(unsigned int level); +static void (*set_irq_line_delay)(unsigned int level); /* DMA Timings */ static const uint8 dma_timing[2][2] = @@ -133,6 +152,9 @@ static void vdp_z80_data_w_m4(unsigned int data); static void vdp_z80_data_w_m5(unsigned int data); static unsigned int vdp_z80_data_r_m4(void); static unsigned int vdp_z80_data_r_m5(void); +static void vdp_z80_data_w_ms(unsigned int data); +static void vdp_z80_data_w_gg(unsigned int data); +static void vdp_z80_data_w_sg(unsigned int data); static void vdp_bus_w(unsigned int data); static void vdp_fifo_update(unsigned int cycles); static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles); @@ -149,10 +171,27 @@ void vdp_init(void) { /* PAL/NTSC timings */ lines_per_frame = vdp_pal ? 313: 262; - status = (status & ~1) | vdp_pal; /* CPU interrupt line(s)*/ - irq_line = (system_hw == SYSTEM_PBC) ? &Z80.irq_state : &m68k_irq_state; + switch (system_hw) + { + case SYSTEM_MD: + case SYSTEM_PICO: + { + /* 68k cpu */ + set_irq_line = m68k_set_irq; + set_irq_line_delay = m68k_set_irq_delay; + break; + } + + default: + { + /* Z80 cpu */ + set_irq_line = z80_set_irq_line; + set_irq_line_delay = z80_set_irq_line; + break; + } + } } void vdp_reset(void) @@ -170,7 +209,6 @@ void vdp_reset(void) border = 0; hint_pending = 0; vint_pending = 0; - m68k_irq_state = 0; dmafill = 0; dma_type = 0; dma_length = 0; @@ -188,7 +226,6 @@ void vdp_reset(void) satb = 0; hscb = 0; - hscroll = 0; vscroll = 0; hscroll_mask = 0x00; @@ -217,7 +254,14 @@ void vdp_reset(void) fifo_latency = 214; /* reset VDP status (FIFO empty flag is set) */ - status = vdp_pal | 0x200; + if (system_hw & SYSTEM_MD) + { + status = vdp_pal | 0x200; + } + else + { + status = 0; + } /* default display area */ bitmap.viewport.w = 256; @@ -226,38 +270,112 @@ void vdp_reset(void) bitmap.viewport.oh = 192; /* default overscan area */ - bitmap.viewport.x = (config.overscan & 2) * 7; - bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1); + if (system_hw == SYSTEM_GG) + { + /* Display area reduced to 160x144 if overscan is disabled */ + bitmap.viewport.x = (config.overscan & 2) ? 14 : -48; + bitmap.viewport.y = (config.overscan & 1) ? (24 * (vdp_pal + 1)) : -24; + } + else + { + bitmap.viewport.x = (config.overscan & 2) * 7; + bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1); + } /* default rendering mode */ - render_bg = render_bg_m4; - render_obj = render_obj_m4; - parse_satb = parse_satb_m4; update_bg_pattern_cache = update_bg_pattern_cache_m4; + if (system_hw < SYSTEM_SMS) + { + /* Mode 0 */ + render_bg = render_bg_m0; + render_obj = render_obj_tms; + parse_satb = parse_satb_tms; + } + else + { + /* Mode 4 */ + render_bg = render_bg_m4; + render_obj = render_obj_m4; + parse_satb = parse_satb_m4; + } - /* reset palette */ + /* default 68k bus access mode (Mode 4) */ + vdp_68k_data_w = vdp_68k_data_w_m4; + vdp_68k_data_r = vdp_68k_data_r_m4; + + /* default Z80 bus access mode */ + switch (system_hw) + { + case SYSTEM_SG: + { + /* SG-1000 port access */ + vdp_z80_data_w = vdp_z80_data_w_sg; + vdp_z80_data_r = vdp_z80_data_r_m4; + break; + } + + case SYSTEM_GG: + { + /* Game Gear port access */ + vdp_z80_data_w = vdp_z80_data_w_gg; + vdp_z80_data_r = vdp_z80_data_r_m4; + break; + } + + case SYSTEM_MARKIII: + case SYSTEM_SMS: + case SYSTEM_SMS2: + case SYSTEM_GGMS: + { + /* Master System port access */ + vdp_z80_data_w = vdp_z80_data_w_ms; + vdp_z80_data_r = vdp_z80_data_r_m4; + break; + } + + default: + { + /* Genesis port access */ + vdp_z80_data_w = vdp_z80_data_w_m4; + vdp_z80_data_r = vdp_z80_data_r_m4; + break; + } + } + + if (system_hw == SYSTEM_SG) + { + /* disable H-INT */ + vdp_reg_w(10, 0xFF, 0); + } + else if ((system_hw > SYSTEM_MARKIII) && (system_hw < SYSTEM_MD)) + { + /* initialize registers normally set by Master System BIOS */ + vdp_reg_w(0 , 0x36, 0); + vdp_reg_w(1 , 0x80, 0); + vdp_reg_w(2 , 0xFF, 0); + vdp_reg_w(3 , 0xFF, 0); + vdp_reg_w(4 , 0xFF, 0); + vdp_reg_w(5 , 0xFF, 0); + vdp_reg_w(6 , 0xFF, 0); + vdp_reg_w(10, 0xFF, 0); + } + else if ((system_hw != SYSTEM_PBC) && (config.tmss == 1)) + { + /* initialize registers if BIOS is simulated */ + vdp_reg_w(0 , 0x04, 0); + vdp_reg_w(1 , 0x04, 0); + vdp_reg_w(10, 0xFF, 0); + vdp_reg_w(12, 0x81, 0); + vdp_reg_w(15, 0x02, 0); + } + + /* reset color palette */ int i; - color_update(0x40, 0x00); for(i = 0; i < 0x20; i ++) { - color_update(i, 0x00); - } - - /* default bus access mode */ - vdp_68k_data_w = vdp_68k_data_w_m4; - vdp_z80_data_w = vdp_z80_data_w_m4; - vdp_68k_data_r = vdp_68k_data_r_m4; - vdp_z80_data_r = vdp_z80_data_r_m4; - - /* initialize some registers if OS ROM is simulated */ - if (config.tmss == 1) - { - vdp_reg_w(0 , 0x04, 0); /* Palette bit set */ - vdp_reg_w(1 , 0x04, 0); /* Mode 5 enabled */ - vdp_reg_w(10, 0xff, 0); /* HINT disabled */ - vdp_reg_w(12, 0x81, 0); /* H40 mode */ - vdp_reg_w(15, 0x02, 0); /* auto increment */ + color_update_m4(i, 0x00); } + color_update_m4(0x40, 0x00); } int vdp_context_save(uint8 *state) @@ -277,15 +395,13 @@ int vdp_context_save(uint8 *state) save_param(&dmafill, sizeof(dmafill)); save_param(&hint_pending, sizeof(hint_pending)); save_param(&vint_pending, sizeof(vint_pending)); - save_param(&m68k_irq_state, sizeof(m68k_irq_state)); save_param(&dma_length, sizeof(dma_length)); save_param(&dma_type, sizeof(dma_type)); save_param(&cached_write, sizeof(cached_write)); - return bufferptr; } -int vdp_context_load(uint8 *state) +int vdp_context_load(uint8 *state, char *version) { int i, bufferptr = 0; uint8 temp_reg[0x20]; @@ -303,15 +419,55 @@ int vdp_context_load(uint8 *state) load_param(&dmafill, sizeof(dmafill)); load_param(&hint_pending, sizeof(hint_pending)); load_param(&vint_pending, sizeof(vint_pending)); - load_param(&m68k_irq_state, sizeof(m68k_irq_state)); + if ((version[11] <= 0x31) && (version[13] <= 0x35)) + { + uint8 dummy; + load_param(&dummy, sizeof(dummy)); + } load_param(&dma_length, sizeof(dma_length)); load_param(&dma_type, sizeof(dma_type)); load_param(&cached_write, sizeof(cached_write)); /* restore VDP registers */ - for (i=0;i<0x20;i++) + if (system_hw < SYSTEM_MD) { - vdp_reg_w(i, temp_reg[i], 0); + /* save internal data */ + uint8 old_pending = pending; + uint8 old_code = code; + uint16 old_addr = addr; + uint16 old_addr_latch = addr_latch; + + if (system_hw > SYSTEM_SG) + { + for (i=0;i<0x10;i++) + { + pending = 1; + addr_latch = temp_reg[i]; + vdp_sms_ctrl_w(0x80 | i); + } + } + else + { + for (i=0;i<0x08;i++) + { + pending = 1; + addr_latch = temp_reg[i]; + vdp_tms_ctrl_w(0x80 | i); + } + } + + /* restore internal data */ + pending = old_pending; + code = old_code; + addr = old_addr; + addr_latch = old_addr_latch; + } + else + { + for (i=0;i<0x20;i++) + { + vdp_reg_w(i, temp_reg[i], 0); + } } /* restore FIFO timings */ @@ -319,7 +475,10 @@ int vdp_context_load(uint8 *state) fifo_latency <<= ((code & 0x0F) == 0x01); /* restore current NTSC/PAL mode */ - status = (status & ~1) | vdp_pal; + if (system_hw & SYSTEM_MD) + { + status = (status & ~1) | vdp_pal; + } if (reg[1] & 0x04) { @@ -327,23 +486,23 @@ int vdp_context_load(uint8 *state) bg_list_index = 0x800; /* reinitialize palette */ - color_update(0, *(uint16 *)&cram[border << 1]); + color_update_m5(0, *(uint16 *)&cram[border << 1]); for(i = 1; i < 0x40; i++) { - color_update(i, *(uint16 *)&cram[i << 1]); + color_update_m5(i, *(uint16 *)&cram[i << 1]); } } else { - /* Mode 4 */ + /* Modes 0,1,2,3,4 */ bg_list_index = 0x200; /* reinitialize palette */ - color_update(0x40, *(uint16 *)&cram[(0x10 | (border & 0x0F)) << 1]); for(i = 0; i < 0x20; i ++) { - color_update(i, *(uint16 *)&cram[i << 1]); + color_update_m4(i, *(uint16 *)&cram[i << 1]); } + color_update_m4(0x40, *(uint16 *)&cram[(0x10 | (border & 0x0F)) << 1]); } /* invalidate cache */ @@ -353,7 +512,6 @@ int vdp_context_load(uint8 *state) bg_name_dirty[i]=0xFF; } - return bufferptr; } @@ -415,7 +573,7 @@ void vdp_dma_update(unsigned int cycles) int dma_bytes = (dma_cycles * rate) / MCYCLES_PER_LINE; #ifdef LOGVDP - error("[%d(%d)][%d(%d)] DMA type %d (%d access/line)(%d cycles left)-> %d access (%d remaining) (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE,dma_type/4, rate, dma_cycles, dma_bytes, dma_length, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] DMA type %d (%d access/line)(%d cycles left)-> %d access (%d remaining) (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE,dma_type/4, rate, dma_cycles, dma_bytes, dma_length, m68k_get_reg(M68K_REG_PC)); #endif /* Check if DMA can be finished before the end of current line */ @@ -627,6 +785,7 @@ void vdp_68k_ctrl_w(unsigned int data) fifo_latency <<= ((code & 0x0F) == 0x01); } +/* Mega Drive VDP control port specific (MS compatibility mode) */ void vdp_z80_ctrl_w(unsigned int data) { switch (pending) @@ -650,7 +809,7 @@ void vdp_z80_ctrl_w(unsigned int data) if ((code & 0x03) == 0x02) { /* VDP register write */ - vdp_reg_w(data & 0x1F, addr_latch, mcycles_z80 + Z80_CYCLE_OFFSET); + vdp_reg_w(data & 0x1F, addr_latch, mcycles_z80); /* Clear pending flag */ pending = 0; @@ -739,8 +898,311 @@ void vdp_z80_ctrl_w(unsigned int data) } } -unsigned int vdp_ctrl_r(unsigned int cycles) +/* Master System & Game Gear VDP control port specific */ +void vdp_sms_ctrl_w(unsigned int data) { + if(pending == 0) + { + /* Update address register LSB */ + addr = (addr & 0x3F00) | (data & 0xFF); + + /* Latch LSB */ + addr_latch = data; + + /* Set LSB pending flag */ + pending = 1; + } + else + { + /* Update address and code registers */ + code = (data >> 6) & 3; + addr = (data << 8 | addr_latch) & 0x3FFF; + + /* Clear pending flag */ + pending = 0; + + if (code == 0) + { + /* Process VRAM read */ + fifo[0] = vram[addr & 0x3FFF]; + + /* Increment address register */ + addr = (addr + 1) & 0x3FFF; + return; + } + + if (code == 2) + { + /* VDP register index (0-15) */ + data &= 0x0F; + + /* Save current VDP mode */ + int prev = (reg[0] & 0x06) | (reg[1] & 0x18); + + /* Write VDP register */ + vdp_reg_w(data, addr_latch, mcycles_z80); + + /* Check VDP mode changes */ + int mode = (reg[0] & 0x06) | (reg[1] & 0x18); + prev ^= mode; + + if (prev) + { + /* Check for extended modes */ + if (system_hw > SYSTEM_SMS) + { + int height; + + if (mode == 0x0E) /* M1=0,M2=1,M3=1,M4=1 */ + { + /* Mode 4 extended (240 lines) */ + height = 240; + + /* Update vertical counter max value */ + vc_max = vc_table[3][vdp_pal]; + } + else if (mode == 0x16) /* M1=1,M2=1,M3=0,M4=1 */ + { + /* Mode 4 extended (224 lines) */ + height = 224; + + /* Update vertical counter max value */ + vc_max = vc_table[1][vdp_pal]; + } + else + { + /* Mode 4 default (224 lines) */ + height = 192; + + /* Default vertical counter max value */ + vc_max = vc_table[0][vdp_pal]; + } + + if (height != bitmap.viewport.h) + { + if (v_counter < bitmap.viewport.h) + { + /* update active display */ + bitmap.viewport.h = height; + + /* update vertical overscan */ + if (config.overscan & 1) + { + bitmap.viewport.y = (240 + 48*vdp_pal - height) >> 1; + } + else + { + if (system_hw == SYSTEM_GG) + { + /* Display area reduced to 160x144 */ + bitmap.viewport.y = (144 - height) / 2; + } + else + { + bitmap.viewport.y = 0; + } + } + } + else + { + /* Changes should be applied on next frame */ + bitmap.viewport.changed |= 2; + } + } + } + + /* Rendering mode */ + switch (mode) + { + case 0x00: /* Graphics I */ + { + render_bg = render_bg_m0; + break; + } + + case 0x10: /* Text */ + { + render_bg = render_bg_m1; + break; + } + + case 0x02: /* Graphics II */ + { + render_bg = render_bg_m2; + break; + } + + case 0x12: /* Text (Extended PG) */ + { + render_bg = render_bg_m1x; + break; + } + + case 0x08: /* Multicolor */ + { + render_bg = render_bg_m3; + break; + } + + case 0x18: /* Invalid (1+3) */ + { + render_bg = render_bg_inv; + break; + } + + case 0x0A: /* Multicolor (Extended PG) */ + { + render_bg = render_bg_m3x; + break; + } + + case 0x1A: /* Invalid (1+2+3) */ + { + render_bg = render_bg_inv; + break; + } + + default: /* Mode 4 */ + { + render_bg = render_bg_m4; + break; + } + } + + /* Mode switching */ + if (prev & 0x04) + { + if (mode & 0x04) + { + /* Mode 4 sprites */ + parse_satb = parse_satb_m4; + render_obj = render_obj_m4; + + /* force BG cache update*/ + bg_list_index = 0x200; + } + else + { + /* TMS-mode sprites */ + parse_satb = parse_satb_tms; + render_obj = render_obj_tms; + + /* BG cache is not used */ + bg_list_index = 0; + } + + /* reinitialize palette */ + int i; + for(i = 0; i < 0x20; i ++) + { + color_update_m4(i, *(uint16 *)&cram[i << 1]); + } + color_update_m4(0x40, *(uint16 *)&cram[(0x10 | (border & 0x0F)) << 1]); + } + } + } + } +} + +/* TMS9918 (SG-1000) VDP control port specific */ +void vdp_tms_ctrl_w(unsigned int data) +{ + if(pending == 0) + { + /* Latch LSB */ + addr_latch = data; + + /* Set LSB pending flag */ + pending = 1; + } + else + { + /* Update address and code registers */ + code = (data >> 6) & 3; + addr = (data << 8 | addr_latch) & 0x3FFF; + + /* Clear pending flag */ + pending = 0; + + if (code == 0) + { + /* Process VRAM read */ + fifo[0] = vram[addr & 0x3FFF]; + + /* Increment address register */ + addr = (addr + 1) & 0x3FFF; + return; + } + + if (code & 2) + { + /* VDP register index (0-7) */ + data &= 0x07; + + /* Write VDP register */ + vdp_reg_w(data, addr_latch, mcycles_z80); + + /* Check VDP mode changes */ + if (data < 2) + { + int mode = (reg[0] & 0x02) | (reg[1] & 0x18); + + /* Rendering mode */ + switch (mode) + { + case 0x00: /* Graphics I */ + { + render_bg = render_bg_m0; + break; + } + + case 0x10: /* Text */ + { + render_bg = render_bg_m1; + break; + } + + case 0x02: /* Graphics II */ + { + render_bg = render_bg_m2; + break; + } + + case 0x12: /* Text (Extended PG) */ + { + render_bg = render_bg_m1x; + break; + } + + case 0x08: /* Multicolor */ + { + render_bg = render_bg_m3; + break; + } + + case 0x18: /* Invalid (1+3) */ + { + render_bg = render_bg_inv; + break; + } + + case 0x0A: /* Multicolor (Extended PG) */ + { + render_bg = render_bg_m3x; + break; + } + + case 0x1A: /* Invalid (1+2+3) */ + { + render_bg = render_bg_inv; + break; + } + } + } + } + } +} + /* * Status register * @@ -757,6 +1219,8 @@ unsigned int vdp_ctrl_r(unsigned int cycles) * 9 Write FIFO empty * 10 - 15 Open Bus */ +unsigned int vdp_68k_ctrl_r(unsigned int cycles) +{ /* Update FIFO flags */ vdp_fifo_update(cycles); @@ -770,6 +1234,12 @@ unsigned int vdp_ctrl_r(unsigned int cycles) /* Return VDP status */ unsigned int temp = status; + /* Clear pending flag */ + pending = 0; + + /* Clear SOVR & SCOL flags */ + status &= 0xFF9F; + /* Display OFF: VBLANK flag is set */ if (!(reg[1] & 0x40)) { @@ -783,35 +1253,104 @@ unsigned int vdp_ctrl_r(unsigned int cycles) temp |= 0x04; } - /* Clear pending flag */ - pending = 0; - - /* Clear SPR/SCOL flags */ - status &= 0xFF9F; - - /* Mode 4 specific */ - if (!(reg[1] & 4)) - { - /* Cycle-accurate VINT flag (required by some Master System games) */ - if ((v_counter == bitmap.viewport.h) && ((cycles / MCYCLES_PER_LINE) > (v_counter + 1))) - { - temp |= 0x80; - } - - /* Clear HINT & VINT pending flags */ - hint_pending = vint_pending = 0; - *irq_line = 0x10; - - /* Clear VINT flag */ - status &= ~0x80; - } - #ifdef LOGVDP - error("[%d(%d)][%d(%d)] VDP status read -> 0x%x (0x%x) (%x)\n", v_counter, cycles/MCYCLES_PER_LINE, cycles, cycles%MCYCLES_PER_LINE, temp, status, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] VDP 68k status read -> 0x%x (0x%x) (%x)\n", v_counter, cycles/MCYCLES_PER_LINE-1, cycles, cycles%MCYCLES_PER_LINE, temp, status, m68k_get_reg(M68K_REG_PC)); #endif return (temp); } +unsigned int vdp_z80_ctrl_r(unsigned int cycles) +{ + /* Update DMA Busy flag (Mega Drive VDP specific) */ + if ((system_hw & SYSTEM_MD) && (status & 2) && !dma_length && (cycles >= dma_endCycles)) + { + status &= 0xFD; + } + + /* Cycle-accurate SOVR & VINT flags */ + int line = (lines_per_frame + (mcycles_z80 / MCYCLES_PER_LINE) - 1) % lines_per_frame; + + /* Check if we are already on next line */ + if (line > v_counter) + { + v_counter = line; + if (line == (bitmap.viewport.h + 1)) + { + /* set VINT flag (immediately cleared after) */ + status |= 0x80; + } + else if ((line >= 0) && (line < bitmap.viewport.h) && !(work_ram[0x1ffb] & cart.special)) + { + /* Check sprites overflow & collision */ + render_line(line); + } + } + + /* Return VDP status */ + unsigned int temp = status; + + /* Clear pending flag */ + pending = 0; + + /* Clear VINT, SOVR & SCOL flags */ + status &= 0xFF1F; + + /* Mega Drive VDP specific */ + if (system_hw & SYSTEM_MD) + { + /* Display OFF: VBLANK flag is set */ + if (!(reg[1] & 0x40)) + { + temp |= 0x08; + } + + /* HBLANK flag */ + if ((cycles % MCYCLES_PER_LINE) < 588) + { + temp |= 0x04; + } + } + else if (reg[0] & 0x04) + { + /* Mode 4 unused bits (fixes PGA Tour Golf) */ + temp |= 0x1F; + } + + /* Cycle-accurate SCOL flag */ + if ((temp & 0x20) && (line == (spr_col >> 8))) + { + if (system_hw & SYSTEM_MD) + { + /* COL flag is set at HCount 0xFF on MD */ + if ((cycles % MCYCLES_PER_LINE) < 105) + { + status |= 0x20; + temp &= ~0x20; + } + } + else + { + /* COL flag is set at the pixel it occurs */ + uint8 hc = hctab[(cycles + SMS_CYCLE_OFFSET + 15) % MCYCLES_PER_LINE]; + if ((hc < (spr_col & 0xff)) || (hc > 0xf3)) + { + status |= 0x20; + temp &= ~0x20; + } + } + } + + /* Clear HINT & VINT pending flags */ + hint_pending = vint_pending = 0; + + /* Clear Z80 interrupt */ + Z80.irq_state = CLEAR_LINE; + +#ifdef LOGVDP + error("[%d(%d)][%d(%d)] VDP Z80 status read -> 0x%x (0x%x) (%x)\n", v_counter, cycles/MCYCLES_PER_LINE-1, cycles, cycles%MCYCLES_PER_LINE, temp, status, Z80.pc.w.l); +#endif + return (temp); +} /*--------------------------------------------------------------------------*/ /* HV Counters */ @@ -851,7 +1390,7 @@ unsigned int vdp_hvc_r(unsigned int cycles) { if (reg[1] & 4) { - /* Mode5: both counters are frozen (Lightgun games, Sunset Riders) */ + /* Mode 5: both counters are frozen (Lightgun games, Sunset Riders) */ temp = hvc_latch & 0xffff; } else @@ -862,7 +1401,7 @@ unsigned int vdp_hvc_r(unsigned int cycles) } #ifdef LOGVDP - error("[%d(%d)][%d(%d)] HVC read -> 0x%x (%x)\n", v_counter, cycles/MCYCLES_PER_LINE, cycles, cycles%MCYCLES_PER_LINE, temp, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] HVC read -> 0x%x (%x)\n", v_counter, (cycles/MCYCLES_PER_LINE-1)%lines_per_frame, cycles, cycles%MCYCLES_PER_LINE, temp, m68k_get_reg(M68K_REG_PC)); #endif return (temp); } @@ -875,7 +1414,7 @@ unsigned int vdp_hvc_r(unsigned int cycles) void vdp_test_w(unsigned int data) { #ifdef LOGERROR - error("Unused VDP Write 0x%x (%08x)\n", data, m68k_get_reg (NULL, M68K_REG_PC)); + error("Unused VDP Write 0x%x (%08x)\n", data, m68k_get_reg(M68K_REG_PC)); #endif } @@ -887,11 +1426,11 @@ void vdp_test_w(unsigned int data) int vdp_68k_irq_ack(int int_level) { #ifdef LOGVDP - error("[%d(%d)][%d(%d)] INT Level %d ack (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE,int_level, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] INT Level %d ack (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE,int_level, m68k_get_reg(M68K_REG_PC)); #endif - /* VINT has higher priority */ - if ((m68k_irq_state & 6) == 6) + /* VINT has higher priority (Fatal Rewind) */ + if (vint_pending & reg[1]) { #ifdef LOGVDP error("---> VINT cleared\n"); @@ -904,11 +1443,10 @@ int vdp_68k_irq_ack(int int_level) /* Update IRQ status */ if (hint_pending & reg[0]) { - m68k_irq_state = 0x14; + m68k_set_irq(4); } else { - m68k_irq_state = 0; m68k_set_irq(0); } } @@ -922,15 +1460,7 @@ int vdp_68k_irq_ack(int int_level) hint_pending = 0; /* Update IRQ status */ - if (vint_pending & reg[1]) - { - m68k_irq_state = 0x16; - } - else - { - m68k_irq_state = 0; - m68k_set_irq(0); - } + m68k_set_irq(0); } return M68K_INT_ACK_AUTOVECTOR; @@ -938,13 +1468,13 @@ int vdp_68k_irq_ack(int int_level) /*--------------------------------------------------------------------------*/ -/* Internal registers access function */ +/* VDP registers update function */ /*--------------------------------------------------------------------------*/ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) { #ifdef LOGVDP - error("[%d(%d)][%d(%d)] VDP register %d write -> 0x%x (%x)\n", v_counter, cycles/MCYCLES_PER_LINE, cycles, cycles%MCYCLES_PER_LINE, r, d, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] VDP register %d write -> 0x%x (%x)\n", v_counter, cycles/MCYCLES_PER_LINE-1, cycles, cycles%MCYCLES_PER_LINE, r, d, m68k_get_reg(M68K_REG_PC)); #endif /* VDP registers #11 to #23 cannot be updated in Mode 4 (Captain Planet & Avengers, Bass Master Classic Pro Edition) */ @@ -965,39 +1495,45 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) if ((r & 0x10) && hint_pending) { /* Update IRQ status */ - *irq_line = 0x30; - if (vint_pending & reg[1]) { - *irq_line |= 0x06; + set_irq_line(6); } else if (d & 0x10) { - *irq_line |= 0x04; + set_irq_line_delay(4); + } + else + { + set_irq_line(0); } } /* Palette selection */ if (r & 0x04) { - /* Reset color palette */ - int i; - if (reg[1] & 0x04) + /* Mega Drive VDP only */ + if (system_hw & SYSTEM_MD) { - /* Mode 5 */ - color_update(0x00, *(uint16 *)&cram[border << 1]); - for (i = 1; i < 0x40; i++) + /* Reset color palette */ + int i; + if (reg[1] & 0x04) { - color_update (i, *(uint16 *)&cram[i << 1]); + /* Mode 5 */ + color_update_m5(0x00, *(uint16 *)&cram[border << 1]); + for (i = 1; i < 0x40; i++) + { + color_update_m5(i, *(uint16 *)&cram[i << 1]); + } } - } - else - { - /* Mode 4 */ - color_update(0x40, *(uint16 *)&cram[(0x10 | (border & 0x0F)) << 1]); - for (i = 0; i < 0x20; i++) + else { - color_update (i, *(uint16 *)&cram[i << 1]); + /* Mode 4 */ + for (i = 0; i < 0x20; i++) + { + color_update_m4(i, *(uint16 *)&cram[i << 1]); + } + color_update_m4(0x40, *(uint16 *)&cram[(0x10 | (border & 0x0F)) << 1]); } } } @@ -1005,18 +1541,22 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) /* HVC latch (Sunset Riders, Lightgun games) */ if (r & 0x02) { - /* Mode 5 only */ - if (reg[1] & 0x04) + /* Mega Drive VDP only */ + if (system_hw & SYSTEM_MD) { - if (d & 0x02) + /* Mode 5 only */ + if (reg[1] & 0x04) { - /* Latch current HVC */ - hvc_latch = vdp_hvc_r(cycles) | 0x10000; - } - else - { - /* Free-running HVC */ - hvc_latch = 0; + if (d & 0x02) + { + /* Latch current HVC */ + hvc_latch = vdp_hvc_r(cycles) | 0x10000; + } + else + { + /* Free-running HVC */ + hvc_latch = 0; + } } } } @@ -1049,7 +1589,7 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) error("Line redrawn (%d sprites) \n",object_count); #endif } - else + else if (system_hw & SYSTEM_MD) { /* Active pixel offset */ if (reg[12] & 1) @@ -1086,149 +1626,164 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) if ((r & 0x20) && vint_pending) { /* Update IRQ status */ - *irq_line = 0x30; - if (d & 0x20) { - *irq_line |= 0x06; + set_irq_line_delay(6); } else if (hint_pending & reg[0]) { - *irq_line |= 0x04; + set_irq_line(4); + } + else + { + set_irq_line(0); } } - /* Active display height (Mode 5 only) */ + /* Active display height */ if (r & 0x08) { - /* Mode 5 only */ - if (d & 0x04) + /* Mega Drive VDP only */ + if (system_hw & SYSTEM_MD) { - if (v_counter < bitmap.viewport.h) + /* Mode 5 only */ + if (d & 0x04) { - /* Update active display height */ - bitmap.viewport.h = 224 + ((d & 8) << 1); - bitmap.viewport.y = (config.overscan & 1) * (8 - (d & 8) + 24*vdp_pal); + if (v_counter < bitmap.viewport.h) + { + /* Update active display height */ + bitmap.viewport.h = 224 + ((d & 8) << 1); + bitmap.viewport.y = (config.overscan & 1) * (8 - (d & 8) + 24*vdp_pal); + } + else + { + /* Changes should be applied on next frame */ + bitmap.viewport.changed |= 2; + } + + /* Update vertical counter max value */ + vc_max = vc_table[(d >> 2) & 3][vdp_pal]; + } + } + } + + /* Rendering mode */ + if (r & 0x04) + { + /* Mega Drive VDP only */ + if (system_hw & SYSTEM_MD) + { + int i; + if (d & 0x04) + { + /* Mode 5 rendering */ + parse_satb = parse_satb_m5; + update_bg_pattern_cache = update_bg_pattern_cache_m5; + if (im2_flag) + { + render_bg = (reg[11] & 0x04) ? render_bg_m5_im2_vs : render_bg_m5_im2; + render_obj = (reg[12] & 0x08) ? render_obj_m5_im2_ste : render_obj_m5_im2; + } + else + { + render_bg = (reg[11] & 0x04) ? render_bg_m5_vs : render_bg_m5; + render_obj = (reg[12] & 0x08) ? render_obj_m5_ste : render_obj_m5; + } + + /* Reset color palette */ + color_update_m5(0x00, *(uint16 *)&cram[border << 1]); + for (i = 1; i < 0x40; i++) + { + color_update_m5(i, *(uint16 *)&cram[i << 1]); + } + + /* Mode 5 bus access */ + vdp_68k_data_w = vdp_68k_data_w_m5; + vdp_z80_data_w = vdp_z80_data_w_m5; + vdp_68k_data_r = vdp_68k_data_r_m5; + vdp_z80_data_r = vdp_z80_data_r_m5; + + /* Change display height */ + if (v_counter < bitmap.viewport.h) + { + /* Update active display */ + bitmap.viewport.h = 224 + ((d & 8) << 1); + bitmap.viewport.y = (config.overscan & 1) * (8 - (d & 8) + 24*vdp_pal); + } + else + { + /* Changes should be applied on next frame */ + bitmap.viewport.changed |= 2; + } + + /* Clear HVC latched value */ + hvc_latch = 0; + + /* Check if HVC latch bit is set */ + if (reg[0] & 0x02) + { + /* Latch current HVC */ + hvc_latch = vdp_hvc_r(cycles) | 0x10000; + } + + /* max tiles to invalidate */ + bg_list_index = 0x800; } else { - /* Changes should be applied on next frame */ - bitmap.viewport.changed |= 2; + /* Mode 4 rendering */ + parse_satb = parse_satb_m4; + update_bg_pattern_cache = update_bg_pattern_cache_m4; + render_bg = render_bg_m4; + render_obj = render_obj_m4; + + /* Reset color palette */ + for (i = 0; i < 0x20; i++) + { + color_update_m4(i, *(uint16 *)&cram[i << 1]); + } + color_update_m4(0x40, *(uint16 *)&cram[(0x10 | (border & 0x0F)) << 1]); + + /* Mode 4 bus access */ + vdp_68k_data_w = vdp_68k_data_w_m4; + vdp_z80_data_w = vdp_z80_data_w_m4; + vdp_68k_data_r = vdp_68k_data_r_m4; + vdp_z80_data_r = vdp_z80_data_r_m4; + + if (v_counter < bitmap.viewport.h) + { + /* Update active display height */ + bitmap.viewport.h = 192; + bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1); + } + else + { + /* Changes should be applied on next frame */ + bitmap.viewport.changed |= 2; + } + + /* Latch current HVC */ + hvc_latch = vdp_hvc_r(cycles) | 0x10000; + + /* max tiles to invalidate */ + bg_list_index = 0x200; + } + + /* Invalidate pattern cache */ + for (i=0;i> 2) & 3][vdp_pal]; } - } - - /* VDP Mode switch */ - if (r & 0x04) - { - int i; - if (d & 0x04) - { - /* Mode 5 rendering */ - parse_satb = parse_satb_m5; - update_bg_pattern_cache = update_bg_pattern_cache_m5; - if (im2_flag) - { - render_bg = (reg[11] & 0x04) ? render_bg_m5_im2_vs : render_bg_m5_im2; - render_obj = (reg[12] & 0x08) ? render_obj_m5_im2_ste : render_obj_m5_im2; - } - else - { - render_bg = (reg[11] & 0x04) ? render_bg_m5_vs : render_bg_m5; - render_obj = (reg[12] & 0x08) ? render_obj_m5_ste : render_obj_m5; - } - - /* Reset color palette */ - color_update(0x00, *(uint16 *)&cram[border << 1]); - for (i = 1; i < 0x40; i++) - { - color_update (i, *(uint16 *)&cram[i << 1]); - } - - /* Mode 5 bus access */ - vdp_68k_data_w = vdp_68k_data_w_m5; - vdp_z80_data_w = vdp_z80_data_w_m5; - vdp_68k_data_r = vdp_68k_data_r_m5; - vdp_z80_data_r = vdp_z80_data_r_m5; - - /* Change display height */ - if (v_counter < bitmap.viewport.h) - { - /* Update active display */ - bitmap.viewport.h = 224 + ((d & 8) << 1); - bitmap.viewport.y = (config.overscan & 1) * (8 - (d & 8) + 24*vdp_pal); - } - else - { - /* Changes should be applied on next frame */ - bitmap.viewport.changed |= 2; - } - - /* Clear HVC latched value */ - hvc_latch = 0; - - /* Check if HVC latch bit is set */ - if (reg[0] & 0x02) - { - /* Latch current HVC */ - hvc_latch = vdp_hvc_r(cycles) | 0x10000; - } - - /* max tiles to invalidate */ - bg_list_index = 0x800; - } else { - /* Mode 4 rendering */ - parse_satb = parse_satb_m4; - update_bg_pattern_cache = update_bg_pattern_cache_m4; - render_bg = render_bg_m4; - render_obj = render_obj_m4; - - /* Reset color palette */ - color_update(0x40, *(uint16 *)&cram[(0x10 | (border & 0x0F)) << 1]); - for (i = 0; i < 0x20; i++) - { - color_update (i, *(uint16 *)&cram[i << 1]); - } - - /* Mode 4 bus access */ - vdp_68k_data_w = vdp_68k_data_w_m4; - vdp_z80_data_w = vdp_z80_data_w_m4; - vdp_68k_data_r = vdp_68k_data_r_m4; - vdp_z80_data_r = vdp_z80_data_r_m4; - - if (v_counter < bitmap.viewport.h) - { - /* Update active display height */ - bitmap.viewport.h = 192; - bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1); - } - else - { - /* Changes should be applied on next frame */ - bitmap.viewport.changed |= 2; - } - - /* Latch current HVC */ - hvc_latch = vdp_hvc_r(cycles) | 0x10000; - - /* max tiles to invalidate */ - bg_list_index = 0x200; + /* No effect (cleared to avoid mode 5 detection elsewhere) */ + reg[1] &= ~0x04; } - - /* Invalidate pattern cache */ - for (i=0;i> 2) & 3][vdp_pal]; } break; } @@ -1284,12 +1839,12 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) if (reg[1] & 4) { /* Mode 5 */ - color_update(0x00, *(uint16 *)&cram[d << 1]); + color_update_m5(0x00, *(uint16 *)&cram[d << 1]); } else { /* Mode 4 */ - color_update(0x40, *(uint16 *)&cram[(0x10 | (d & 0x0F)) << 1]); + color_update_m4(0x40, *(uint16 *)&cram[(0x10 | (d & 0x0F)) << 1]); } /* Backdrop color modified during HBLANK (Road Rash 1,2,3)*/ @@ -1313,18 +1868,25 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) break; } - case 8: /* HSCROLL (Mode 4) */ + case 8: /* Horizontal Scroll (Mode 4 only) */ { - reg[8] = d; - - /* HScroll is latched at the start of a line */ - /* so make sure we are not already next line */ - if ((cycles - Z80_CYCLE_OFFSET) < (mcycles_vdp + MCYCLES_PER_LINE - 4)) + /* Hscroll is latched at HCount 0xF3, HCount 0xF6 on MD */ + /* Line starts at HCount 0xF4, HCount 0xF6 on MD */ + if (system_hw < SYSTEM_MD) { - /* Update Hscroll data for next line */ - hscroll = d; + cycles = cycles + 15; } - break; + + /* Make sure Hscroll has not already been latched */ + int line = (lines_per_frame + (cycles / MCYCLES_PER_LINE) - 1) % lines_per_frame; + if ((line > v_counter) && (line < bitmap.viewport.h) && !(work_ram[0x1ffb] & cart.special)) + { + v_counter = line; + render_line(line); + } + + reg[8] = d; + break; } case 11: /* CTRL #3 */ @@ -1357,10 +1919,10 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) { /* Reset color palette */ int i; - color_update(0x00, *(uint16 *)&cram[border << 1]); + color_update_m5(0x00, *(uint16 *)&cram[border << 1]); for (i = 1; i < 0x40; i++) { - color_update (i, *(uint16 *)&cram[i << 1]); + color_update_m5(i, *(uint16 *)&cram[i << 1]); } /* Update sprite rendering function */ @@ -1475,7 +2037,7 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) /*--------------------------------------------------------------------------*/ -/* FIFO update function */ +/* FIFO update function (Genesis mode only) */ /*--------------------------------------------------------------------------*/ static void vdp_fifo_update(unsigned int cycles) @@ -1520,7 +2082,7 @@ static void vdp_bus_w(unsigned int data) case 0x01: /* VRAM */ { #ifdef LOGVDP - error("[%d(%d)][%d(%d)] VRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] VRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg(M68K_REG_PC)); #endif /* Byte-swap data if A0 is set */ if (addr & 1) @@ -1557,7 +2119,7 @@ static void vdp_bus_w(unsigned int data) case 0x03: /* CRAM */ { #ifdef LOGVDP - error("[%d(%d)][%d(%d)] CRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] CRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg(M68K_REG_PC)); #endif /* Pointer to CRAM 9-bit word */ uint16 *p = (uint16 *)&cram[addr & 0x7E]; @@ -1578,13 +2140,13 @@ static void vdp_bus_w(unsigned int data) if (index & 0x0F) { /* Update color palette */ - color_update(index, data); + color_update_m5(index, data); } /* Update backdrop color */ if (index == border) { - color_update(0x00, data); + color_update_m5(0x00, data); } /* CRAM modified during HBLANK (Striker, Zero the Kamikaze, etc) */ @@ -1606,7 +2168,7 @@ static void vdp_bus_w(unsigned int data) case 0x05: /* VSRAM */ { #ifdef LOGVDP - error("[%d(%d)][%d(%d)] VSRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] VSRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg(M68K_REG_PC)); #endif *(uint16 *)&vsram[addr & 0x7E] = data; break; @@ -1615,7 +2177,7 @@ static void vdp_bus_w(unsigned int data) #ifdef LOGERROR default: { - error("[%d(%d)][%d(%d)] Unknown (%d) 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, code, addr, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] Unknown (%d) 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, code, addr, data, m68k_get_reg(M68K_REG_PC)); break; } #endif @@ -1635,6 +2197,32 @@ static void vdp_68k_data_w_m4(unsigned int data) /* Clear pending flag */ pending = 0; + /* Restricted VDP writes during active display */ + if (!(status & 8) && (reg[1] & 0x40)) + { + /* Update VDP FIFO */ + vdp_fifo_update(mcycles_68k); + + /* Clear FIFO empty flag */ + status &= 0xFDFF; + + /* 4 words can be stored */ + if (fifo_write_cnt < 4) + { + /* Increment FIFO counter */ + fifo_write_cnt++; + + /* Set FIFO full flag if 4 words are stored */ + status |= ((fifo_write_cnt & 4) << 6); + } + else + { + /* CPU is locked until last FIFO entry has been processed (Chaos Engine, Soldiers of Fortune, Double Clutch) */ + fifo_lastwrite += fifo_latency; + mcycles_68k = fifo_lastwrite; + } + } + /* Check destination code */ if (code & 0x02) { @@ -1654,12 +2242,12 @@ static void vdp_68k_data_w_m4(unsigned int data) *p = data; /* Update color palette */ - color_update(index, data); + color_update_m4(index, data); /* Update backdrop color */ if (index == (0x10 | (border & 0x0F))) { - color_update(0x40, data); + color_update_m4(0x40, data); } } } @@ -1778,7 +2366,7 @@ static unsigned int vdp_68k_data_r_m5(void) data = *(uint16 *)&vram[addr & 0xFFFE]; #ifdef LOGVDP - error("[%d(%d)][%d(%d)] VRAM 0x%x read -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] VRAM 0x%x read -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg(M68K_REG_PC)); #endif break; } @@ -1789,7 +2377,7 @@ static unsigned int vdp_68k_data_r_m5(void) data = *(uint16 *)&vsram[addr & 0x7E]; #ifdef LOGVDP - error("[%d(%d)][%d(%d)] VSRAM 0x%x read -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] VSRAM 0x%x read -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg(M68K_REG_PC)); #endif break; } @@ -1803,7 +2391,7 @@ static unsigned int vdp_68k_data_r_m5(void) data = ((data & 0x1C0) << 3) | ((data & 0x038) << 2) | ((data & 0x007) << 1); #ifdef LOGVDP - error("[%d(%d)][%d(%d)] CRAM 0x%x read -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] CRAM 0x%x read -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg(M68K_REG_PC)); #endif break; } @@ -1812,7 +2400,7 @@ static unsigned int vdp_68k_data_r_m5(void) { /* Invalid code value */ #ifdef LOGERROR - error("[%d(%d)][%d(%d)] Invalid (%d) 0x%x read (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, code, addr, m68k_get_reg (NULL, M68K_REG_PC)); + error("[%d(%d)][%d(%d)] Invalid (%d) 0x%x read (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE-1, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, code, addr, m68k_get_reg(M68K_REG_PC)); #endif break; } @@ -1827,7 +2415,7 @@ static unsigned int vdp_68k_data_r_m5(void) /*--------------------------------------------------------------------------*/ -/* Z80 data port access functions (MS compatibilty mode) */ +/* Z80 data port access functions (Master System compatibilty mode) */ /*--------------------------------------------------------------------------*/ static void vdp_z80_data_w_m4(unsigned int data) @@ -1841,7 +2429,7 @@ static void vdp_z80_data_w_m4(unsigned int data) /* CRAM index (32 words) */ int index = addr & 0x1F; - /* Pointer to CRAM 9-bit word */ + /* Pointer to CRAM word */ uint16 *p = (uint16 *)&cram[index << 1]; /* Check if CRAM data is being modified */ @@ -1851,12 +2439,12 @@ static void vdp_z80_data_w_m4(unsigned int data) *p = data; /* Update color palette */ - color_update(index, data); + color_update_m4(index, data); /* Update backdrop color */ if (index == (0x10 | (border & 0x0F))) { - color_update(0x40, data); + color_update_m4(0x40, data); } } } @@ -1873,7 +2461,7 @@ static void vdp_z80_data_w_m4(unsigned int data) /* Update pattern cache */ int name; - MARK_BG_DIRTY (index); + MARK_BG_DIRTY(index); } } @@ -1916,7 +2504,7 @@ static void vdp_z80_data_w_m5(unsigned int data) case 0x03: /* CRAM */ { - /* Pointer to CRAM 9-bit word */ + /* Pointer to CRAM word */ uint16 *p = (uint16 *)&cram[addr & 0x7E]; /* Pack 8-bit value into 9-bit CRAM data */ @@ -1944,13 +2532,13 @@ static void vdp_z80_data_w_m5(unsigned int data) if (index & 0x0F) { /* Update color palette */ - color_update(index, data); + color_update_m5(index, data); } /* Update backdrop color */ if (index == border) { - color_update(0x00, data); + color_update_m5(0x00, data); } } break; @@ -1999,7 +2587,7 @@ static unsigned int vdp_z80_data_r_m4(void) /* Process next read */ fifo[0] = vram[addr & 0x3FFF]; - /* Increment address register */ + /* Increment address register (register #15 can only be set in Mode 5) */ addr += (reg[15] + 1); /* Return data */ @@ -2048,7 +2636,7 @@ static unsigned int vdp_z80_data_r_m5(void) } } - /* Increment address register (TODO: see how address is incremented in Mode 5) */ + /* Increment address register */ addr += reg[15]; /* Return data */ @@ -2056,6 +2644,169 @@ static unsigned int vdp_z80_data_r_m5(void) } +/*-----------------------------------------------------------------------------*/ +/* VDP specific data port access functions (Master System, Game Gear, SG-1000) */ +/*-----------------------------------------------------------------------------*/ + +static void vdp_z80_data_w_ms(unsigned int data) +{ + /* Clear pending flag */ + pending = 0; + + if (code < 3) + { + /* check if we are already on next line */ + int line = (lines_per_frame + (mcycles_z80 / MCYCLES_PER_LINE) - 1) % lines_per_frame; + if ((line > v_counter) && (line < bitmap.viewport.h) && !(work_ram[0x1ffb] & cart.special)) + { + v_counter = line; + render_line(line); + } + + /* VRAM address */ + int index = addr & 0x3FFF; + +#ifdef LOGVDP + error("[%d(%d)][%d(%d)] VRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_z80/MCYCLES_PER_LINE-1, mcycles_z80, mcycles_z80%MCYCLES_PER_LINE, index, data, Z80.pc.w.l); +#endif + + /* VRAM write */ + if(data != vram[index]) + { + int name; + vram[index] = data; + MARK_BG_DIRTY(index); + } + } + else + { +#ifdef LOGVDP + error("[%d(%d)][%d(%d)] CRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_z80/MCYCLES_PER_LINE-1, mcycles_z80, mcycles_z80%MCYCLES_PER_LINE, addr, data, Z80.pc.w.l); +#endif + /* CRAM address */ + int index = addr & 0x1F; + + /* Pointer to CRAM word */ + uint16 *p = (uint16 *)&cram[index << 1]; + + /* Check if CRAM data is being modified */ + if (data != *p) + { + /* Write CRAM data */ + *p = data; + + /* Update color palette */ + color_update_m4(index, data); + + /* Update backdrop color */ + if (index == (0x10 | (border & 0x0F))) + { + color_update_m4(0x40, data); + } + } + } + + /* Update read buffer */ + fifo[0] = data; + + /* Update address register */ + addr++; +} + +static void vdp_z80_data_w_gg(unsigned int data) +{ + /* Clear pending flag */ + pending = 0; + + if (code < 3) + { + /* check if we are already on next line*/ + int line = (lines_per_frame + (mcycles_z80 / MCYCLES_PER_LINE) - 1) % lines_per_frame; + if ((line > v_counter) && (line < bitmap.viewport.h) && !(work_ram[0x1ffb] & cart.special)) + { + v_counter = line; + render_line(line); + } + + /* VRAM address */ + int index = addr & 0x3FFF; + +#ifdef LOGVDP + error("[%d(%d)][%d(%d)] VRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_z80/MCYCLES_PER_LINE-1, mcycles_z80, mcycles_z80%MCYCLES_PER_LINE, index, data, Z80.pc.w.l); +#endif + + /* VRAM write */ + if(data != vram[index]) + { + int name; + vram[index] = data; + MARK_BG_DIRTY(index); + } + } + else + { + if(addr & 1) + { + /* 12-bit data word */ + data = (data << 8) | cached_write; + + /* Pointer to CRAM word */ + uint16 *p = (uint16 *)&cram[addr & 0x3E]; + + /* Check if CRAM data is being modified */ + if (data != *p) + { + /* Write CRAM data */ + *p = data; + + /* Color index (0-31) */ + int index = (addr >> 1) & 0x1F; + + /* Update color palette */ + color_update_m4(index, data); + + /* Update backdrop color */ + if (index == (0x10 | (border & 0x0F))) + { + color_update_m4(0x40, data); + } + } + } + else + { + /* Latch LSB */ + cached_write = data; + } + } + + /* Update read buffer */ + fifo[0] = data; + + /* Update address register */ + addr++; +} + +static void vdp_z80_data_w_sg(unsigned int data) +{ + /* Clear pending flag */ + pending = 0; + + /* VRAM address */ + int index = addr & 0x3FFF; + + /* 4K address decoding (cf. tms9918a.txt) */ + if (!(reg[1] & 0x80)) + { + index = (index & 0x203F) | ((index >> 6) & 0x40) | ((index << 1) & 0x1F80); + } + + /* VRAM write */ + vram[index] = data; + + /* Update address register */ + addr++; +} + /*--------------------------------------------------------------------------*/ /* DMA operations */ /*--------------------------------------------------------------------------*/ diff --git a/source/vdp_ctrl.h b/source/vdp_ctrl.h index 2e742e6..dbc1bf9 100644 --- a/source/vdp_ctrl.h +++ b/source/vdp_ctrl.h @@ -2,22 +2,40 @@ * Genesis Plus * Video Display Processor (68k & Z80 CPU interface) * + * Support for SG-1000, Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP + * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -32,7 +50,6 @@ extern uint8 cram[0x80]; extern uint8 vsram[0x80]; extern uint8 hint_pending; extern uint8 vint_pending; -extern uint8 m68k_irq_state; extern uint16 status; extern uint32 dma_length; @@ -56,7 +73,6 @@ extern uint8 interlaced; extern uint8 vdp_pal; extern uint16 v_counter; extern uint16 vc_max; -extern uint16 hscroll; extern uint16 vscroll; extern uint16 lines_per_frame; extern int32 fifo_write_cnt; @@ -74,11 +90,14 @@ extern unsigned int (*vdp_z80_data_r)(void); extern void vdp_init(void); extern void vdp_reset(void); extern int vdp_context_save(uint8 *state); -extern int vdp_context_load(uint8 *state); +extern int vdp_context_load(uint8 *state, char *version); extern void vdp_dma_update(unsigned int cycles); extern void vdp_68k_ctrl_w(unsigned int data); extern void vdp_z80_ctrl_w(unsigned int data); -extern unsigned int vdp_ctrl_r(unsigned int cycles); +extern void vdp_sms_ctrl_w(unsigned int data); +extern void vdp_tms_ctrl_w(unsigned int data); +extern unsigned int vdp_68k_ctrl_r(unsigned int cycles); +extern unsigned int vdp_z80_ctrl_r(unsigned int cycles); extern unsigned int vdp_hvc_r(unsigned int cycles); extern void vdp_test_w(unsigned int data); extern int vdp_68k_irq_ack(int int_level); diff --git a/source/vdp_render.c b/source/vdp_render.c index 2e68094..acacfaf 100644 --- a/source/vdp_render.c +++ b/source/vdp_render.c @@ -1,23 +1,41 @@ /*************************************************************************************** * Genesis Plus - * Video Display Processor (Mode 4 & Mode 5 rendering) + * Video Display Processor (Modes 0, 1, 2, 3, 4 & 5 rendering) + * + * Support for SG-1000, Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP * * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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. + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. * - * 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 + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -389,8 +407,45 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) { \ temp |= (lb[i] << 8); \ lb[i] = TABLE[temp | ATTR]; \ - if (temp & 0x8000) \ + status |= ((temp & 0x8000) >> 10); \ + } \ + } + +#define DRAW_SPRITE_TILE_ACCURATE(WIDTH,ATTR,TABLE) \ + for (i=0;i> 1); \ + status |= 0x20; \ + } \ + } \ + } + +#define DRAW_SPRITE_TILE_ACCURATE_2X(WIDTH,ATTR,TABLE) \ + for (i=0;i> 1); \ + status |= 0x20; \ + } \ + temp &= 0x00FF; \ + temp |= (lb[i+1] << 8); \ + lb[i+1] = TABLE[temp | ATTR]; \ + if ((temp & 0x8000) && !(status & 0x20)) \ + { \ + spr_col = (v_counter << 8) | ((xpos + i + 1 + 13) >> 1); \ status |= 0x20; \ } \ } \ @@ -400,14 +455,21 @@ static __inline__ void WRITE_LONG(void *address, uint32 data) /* Pixel conversion macros */ /* 4-bit color channels are either compressed to 2/3-bit or dithered to 5/6/8-bit equivalents */ /* 3:3:2 RGB */ -#define MAKE_PIXEL_8(r,g,b) (((r) >> 1) << 5 | ((g) >> 1) << 2 | (b) >> 2) -/* 5:5:5 RGB */ -#define MAKE_PIXEL_15(r,g,b) ((r) << 11 | ((r) >> 3) << 10 | (g) << 6 | ((g) >> 3) << 5 | (b) << 1 | (b) >> 3) -/* 5:6:5 RGB */ -#define MAKE_PIXEL_16(r,g,b) ((r) << 12 | ((r) >> 3) << 11 | (g) << 7 | ((g) >> 2) << 5 | (b) << 1 | (b) >> 3) -/* 8:8:8 RGB */ -#define MAKE_PIXEL_32(r,g,b) ((r) << 20 | (r) << 16 | (g) << 12 | (g) << 8 | (b) << 4 | (b)) +#if defined(USE_8BPP_RENDERING) +#define MAKE_PIXEL(r,g,b) (((r) >> 1) << 5 | ((g) >> 1) << 2 | (b) >> 2) +/* 5:5:5 RGB */ +#elif defined(USE_15BPP_RENDERING) +#define MAKE_PIXEL(r,g,b) ((r) << 11 | ((r) >> 3) << 10 | (g) << 6 | ((g) >> 3) << 5 | (b) << 1 | (b) >> 3) + +/* 5:6:5 RGB */ +#elif defined(USE_16BPP_RENDERING) +#define MAKE_PIXEL(r,g,b) ((r) << 12 | ((r) >> 3) << 11 | (g) << 7 | ((g) >> 2) << 5 | (b) << 1 | (b) >> 3) + +/* 8:8:8 RGB */ +#elif defined(USE_32BPP_RENDERING) +#define MAKE_PIXEL(r,g,b) ((r) << 20 | (r) << 16 | (g) << 12 | (g) << 8 | (b) << 4 | (b)) +#endif /* Window & Plane A clipping */ static struct clip_t @@ -430,6 +492,53 @@ static const uint32 atex_table[] = 0x70707070 }; +/* fixed Master System palette for Modes 0,1,2,3 */ +static const uint8 tms_crom[16] = +{ + 0x00, 0x00, 0x08, 0x0C, + 0x10, 0x30, 0x01, 0x3C, + 0x02, 0x03, 0x05, 0x0F, + 0x04, 0x33, 0x15, 0x3F +}; + +/* original SG-1000 palette */ +#if defined(USE_8BPP_RENDERING) +static const uint8 tms_palette[16] = +{ + 0x00, 0x00, 0x39, 0x79, + 0x4B, 0x6F, 0xC9, 0x5B, + 0xE9, 0xED, 0xD5, 0xD9, + 0x35, 0xCE, 0xDA, 0xFF +}; + +#elif defined(USE_15BPP_RENDERING) +static const uint16 tms_palette[16] = +{ + 0x0000, 0x0000, 0x1308, 0x2F6F, + 0x295D, 0x3DDF, 0x6949, 0x23BE, + 0x7D4A, 0x7DEF, 0x6B0A, 0x7330, + 0x12A7, 0x6177, 0x6739, 0x7FFF +}; + +#elif defined(USE_16BPP_RENDERING) +static const uint16 tms_palette[16] = +{ + 0x0000, 0x0000, 0x2648, 0x5ECF, + 0x52BD, 0x7BBE, 0xD289, 0x475E, + 0xF2AA, 0xFBCF, 0xD60A, 0xE670, + 0x2567, 0xC2F7, 0xCE59, 0xFFFF +}; + +#elif defined(USE_32BPP_RENDERING) +static const uint32 tms_palette[16] = +{ + 0x000000, 0x000000, 0x21C842, 0x5EDC78, + 0x5455ED, 0x7D76FC, 0xD4524D, 0x42EBF5, + 0xFC5554, 0xFF7978, 0xD4C154, 0xE6CE80, + 0x21B03B, 0xC95BB4, 0xCCCCCC, 0xFFFFFF +}; +#endif + /* Sprite pattern name offset look-up table (Mode 5) */ static uint8 name_lut[0x400]; @@ -439,35 +548,36 @@ static uint32 bp_lut[0x10000]; /* Layer priority pixel look-up tables */ static uint8 lut[LUT_MAX][LUT_SIZE]; -#ifdef NGC -/* 16-bit pixel color mapping */ +/* 8-bit pixel color mapping */ +#if defined(USE_8BPP_RENDERING) +static uint8 pixel[0x100]; +static uint8 pixel_lut[3][0x200]; +static uint8 pixel_lut_m4[0x40]; + +/* 15-bit pixel color mapping */ +#elif defined(USE_15BPP_RENDERING) static uint16 pixel[0x100]; static uint16 pixel_lut[3][0x200]; static uint16 pixel_lut_m4[0x40]; -#else -/* 8-bit pixel color mapping */ -static uint8 pixel_8[0x100]; -static uint8 pixel_8_lut[3][0x200]; -static uint8 pixel_8_lut_m4[0x40]; -/* 15-bit pixel color mapping */ -static uint16 pixel_15[0x100]; -static uint16 pixel_15_lut[3][0x200]; -static uint16 pixel_15_lut_m4[0x40]; + /* 16-bit pixel color mapping */ -static uint16 pixel_16[0x100]; -static uint16 pixel_16_lut[3][0x200]; -static uint16 pixel_16_lut_m4[0x40]; +#elif defined(USE_16BPP_RENDERING) +static uint16 pixel[0x100]; +static uint16 pixel_lut[3][0x200]; +static uint16 pixel_lut_m4[0x40]; + /* 32-bit pixel color mapping */ -static uint32 pixel_32[0x100]; -static uint32 pixel_32_lut[3][0x200]; -static uint32 pixel_32_lut_m4[0x40]; +#elif defined(USE_32BPP_RENDERING) +static uint32 pixel[0x100]; +static uint32 pixel_lut[3][0x200]; +static uint32 pixel_lut_m4[0x40]; #endif /* Background & Sprite line buffers */ static uint8 linebuf[2][0x200]; /* Sprite limit flag */ -static int spr_over = 0; +static uint8 spr_ovr; /* Sprites parsing */ static struct @@ -478,18 +588,18 @@ static struct uint16 size; } object_info[20]; +/* Sprite Counter */ uint8 object_count; +/* Sprite Collision Info */ +uint16 spr_col; + /* Function pointers */ void (*render_bg)(int line, int width); void (*render_obj)(int max_width); void (*parse_satb)(int line); void (*update_bg_pattern_cache)(int index); -#ifndef NGC -void (*color_update)(int index, unsigned int data); -#endif - /*--------------------------------------------------------------------------*/ /* Sprite pattern name offset look-up table function (Mode 5) */ @@ -812,11 +922,13 @@ static uint32 make_lut_bgobj_m4(uint32 bx, uint32 sx) int s = (sx & 0x0F); int sf = (s | 0x10); /* force palette bit */ + /* Transparent sprite pixel */ if(s == 0) return bx; /* Previous sprite has higher priority */ if(bs) return bx; + /* note: priority bit is always 0 for Modes 0,1,2,3 */ int c = (bp ? (b ? bf : sf) : sf); return (c | 0x80); @@ -837,42 +949,6 @@ static inline void merge(uint8 *srca, uint8 *srcb, uint8 *dst, uint8 *table, int } -#ifndef NGC - -/*--------------------------------------------------------------------------*/ -/* Pixel color mapping functions */ -/*--------------------------------------------------------------------------*/ - -static inline void remap_8(uint8 *src, uint8 *dst, int length) -{ - do - { - *dst++ = pixel_8[*src++]; - } - while (--length); -} - -static inline void remap_16(uint8 *src, uint16 *dst, int length) -{ - do - { - *dst++ = pixel_16[*src++]; - } - while (--length); -} - -static inline void remap_32(uint8 *src, uint32 *dst, int length) -{ - do - { - *dst++ = pixel_32[*src++]; - } - while (--length); -} - -#endif - - /*--------------------------------------------------------------------------*/ /* Pixel color lookup tables initialization */ /*--------------------------------------------------------------------------*/ @@ -891,69 +967,35 @@ static void palette_init(void) /* shadow : 0xxx (0-7) */ /* highlight: 1xxx - 1 (7-14) */ /* mode4 : xx00 ? (0-12) */ + /* GG mode : xxxx (0-16) */ /* */ - /* with x = original 2-bit or 3-bit CRAM value */ + /* with x = original CRAM value (2, 3 or 4-bit) */ /************************************************/ /* Initialize Mode 5 pixel color look-up tables */ for (i = 0; i < 0x200; i++) { - /* CRAM value in mode 5 (BBBGGGRRR) */ + /* CRAM 9-bit value (BBBGGGRRR) */ r = (i >> 0) & 7; g = (i >> 3) & 7; b = (i >> 6) & 7; /* Convert to output pixel format */ -#ifdef NGC - /* 5:6:5 RGB */ - pixel_lut[0][i] = MAKE_PIXEL_16(r,g,b); - pixel_lut[1][i] = MAKE_PIXEL_16(r<<1,g<<1,b<<1); - pixel_lut[2][i] = MAKE_PIXEL_16(r+7,g+7,b+7); -#else - /* 3:3:2 RGB */ - pixel_8_lut[0][i] = MAKE_PIXEL_8(r,g,b); - pixel_8_lut[1][i] = MAKE_PIXEL_8(r<<1,g<<1,b<<1); - pixel_8_lut[2][i] = MAKE_PIXEL_8(r+7,g+7,b+7); - - /* 5:5:5 RGB */ - pixel_15_lut[0][i] = MAKE_PIXEL_15(r,g,b); - pixel_15_lut[1][i] = MAKE_PIXEL_15(r<<1,g<<1,b<<1); - pixel_15_lut[2][i] = MAKE_PIXEL_15(r+7,g+7,b+7); - - /* 5:6:5 RGB */ - pixel_16_lut[0][i] = MAKE_PIXEL_16(r,g,b); - pixel_16_lut[1][i] = MAKE_PIXEL_16(r<<1,g<<1,b<<1); - pixel_16_lut[2][i] = MAKE_PIXEL_16(r+7,g+7,b+7); - - /* 8:8:8 RGB */ - pixel_32_lut[0][i] = MAKE_PIXEL_32(r,g,b); - pixel_32_lut[1][i] = MAKE_PIXEL_32(r<<1,g<<1,b<<1); - pixel_32_lut[2][i] = MAKE_PIXEL_32(r+7,g+7,b+7); -#endif + pixel_lut[0][i] = MAKE_PIXEL(r,g,b); + pixel_lut[1][i] = MAKE_PIXEL(r<<1,g<<1,b<<1); + pixel_lut[2][i] = MAKE_PIXEL(r+7,g+7,b+7); } /* Initialize Mode 4 pixel color look-up table */ for (i = 0; i < 0x40; i++) { - /* CRAM value in mode 4 (000BBGGRR) */ + /* CRAM 6-bit value (000BBGGRR) */ r = (i >> 0) & 3; g = (i >> 2) & 3; b = (i >> 4) & 3; /* Convert to output pixel format (expand to 4-bit for brighter colors ?) */ -#ifdef NGC - /* 5:6:5 RGB */ - pixel_lut_m4[i] = MAKE_PIXEL_16(r << 2,g << 2,b<< 2); -#else - /* 3:3:2 RGB */ - pixel_8_lut_m4[i] = MAKE_PIXEL_8(r << 2,g << 2,b<< 2); - /* 5:5:5 RGB */ - pixel_15_lut_m4[i] = MAKE_PIXEL_15(r << 2,g << 2,b<< 2); - /* 5:6:5 RGB */ - pixel_16_lut_m4[i] = MAKE_PIXEL_16(r << 2,g << 2,b<< 2); - /* 8:8:8 RGB */ - pixel_32_lut_m4[i] = MAKE_PIXEL_32(r << 2,g << 2,b<< 2); -#endif + pixel_lut_m4[i] = MAKE_PIXEL(r << 2,g << 2,b<< 2); } } @@ -962,300 +1004,429 @@ static void palette_init(void) /* Color palette update functions */ /*--------------------------------------------------------------------------*/ -#ifndef NGC - -static void color_update_8(int index, unsigned int data) +void color_update_m4(int index, unsigned int data) { - /* Mode 5 */ - if (reg[1] & 4) + switch (system_hw) { - /* VDP Palette Selection bit */ - if (!(reg[0] & 4)) + case SYSTEM_GG: { - /* Color value is limited to 00X00X00X */ - data &= 0x49; + /* CRAM value (BBBBGGGGRRRR) */ + int r = (data >> 0) & 0x0F; + int g = (data >> 4) & 0x0F; + int b = (data >> 8) & 0x0F; + + /* Convert to output pixel */ + data = MAKE_PIXEL(r,g,b); + break; } - if(reg[12] & 8) + case SYSTEM_SG: { - /* Mode 5 (Shadow/Normal/Highlight) */ - pixel_8[0x00 | index] = pixel_8_lut[0][data]; - pixel_8[0x40 | index] = pixel_8_lut[1][data]; - pixel_8[0x80 | index] = pixel_8_lut[2][data]; - } - else - { - /* Mode 5 (Normal) */ - data = pixel_8_lut[1][data]; - - /* Output pixel: xxiiiiii */ - pixel_8[0x00 | index] = data; - pixel_8[0x40 | index] = data; - pixel_8[0x80 | index] = data; - } - } - else - { - /* Test M4 bit */ - if (reg[0] & 4) - { - /* Mode 4 */ - data = pixel_8_lut_m4[data & 0x3F]; - } - else - { - /* Invalid Mode (black screen) */ - data = 0x00; + /* Fixed TMS9918 palette */ + if (index & 0x0F) + { + /* Colors 1-15 */ + data = tms_palette[index & 0x0F]; + } + else + { + /* Backdrop color */ + data = tms_palette[reg[7] & 0x0F]; + } + break; } - /* Output pixel: x0xiiiii */ - /* Backdrop pixel: 01000000 */ - pixel_8[0x00 | index] = data; - pixel_8[0x20 | index] = data; - pixel_8[0x80 | index] = data; - pixel_8[0xA0 | index] = data; - } -} + default: + { + /* Test M4 bit */ + if (!(reg[0] & 0x04)) + { + if (system_hw & SYSTEM_MD) + { + /* Invalid Mode (black screen) */ + data = 0x00; + } + else if (system_hw != SYSTEM_GGMS) + { + /* Fixed CRAM palette */ + if (index & 0x0F) + { + /* Colors 1-15 */ + data = tms_crom[index & 0x0F]; + } + else + { + /* Backdrop color */ + data = tms_crom[reg[7] & 0x0F]; + } + } + } -static void color_update_15(int index, unsigned int data) -{ - /* Mode 5 */ - if (reg[1] & 4) - { - /* VDP Palette Selection bit */ - if (!(reg[0] & 4)) - { - /* Color value is limited to 00X00X00X */ - data &= 0x49; - } - - if(reg[12] & 8) - { - /* Mode 5 (Shadow/Normal/Highlight) */ - pixel_15[0x00 | index] = pixel_15_lut[0][data]; - pixel_15[0x40 | index] = pixel_15_lut[1][data]; - pixel_15[0x80 | index] = pixel_15_lut[2][data]; - } - else - { - /* Mode 5 (Normal) */ - data = pixel_15_lut[1][data]; - - /* Output pixel: xxiiiiii */ - pixel_15[0x00 | index] = data; - pixel_15[0x40 | index] = data; - pixel_15[0x80 | index] = data; - } - } - else - { - /* Test M4 bit */ - if (reg[0] & 4) - { - /* Mode 4 */ - data = pixel_15_lut_m4[data & 0x3F]; - } - else - { - /* Invalid Mode (black screen) */ - data = 0x00; - } - - /* Output pixel: x0xiiiii */ - /* Backdrop pixel: 01000000 */ - pixel_15[0x00 | index] = data; - pixel_15[0x20 | index] = data; - pixel_15[0x80 | index] = data; - pixel_15[0xA0 | index] = data; - } -} - -static void color_update_16(int index, unsigned int data) -{ - /* Mode 5 */ - if (reg[1] & 4) - { - /* VDP Palette Selection bit */ - if (!(reg[0] & 4)) - { - /* Color value is limited to 00X00X00X */ - data &= 0x49; - } - - if(reg[12] & 8) - { - /* Mode 5 (Shadow/Normal/Highlight) */ - pixel_16[0x00 | index] = pixel_16_lut[0][data]; - pixel_16[0x40 | index] = pixel_16_lut[1][data]; - pixel_16[0x80 | index] = pixel_16_lut[2][data]; - } - else - { - /* Mode 5 (Normal) */ - data = pixel_16_lut[1][data]; - - /* Output pixel: xxiiiiii */ - pixel_16[0x00 | index] = data; - pixel_16[0x40 | index] = data; - pixel_16[0x80 | index] = data; - } - } - else - { - /* Test M4 bit */ - if (reg[0] & 4) - { - /* Mode 4 */ - data = pixel_16_lut_m4[data & 0x3F]; - } - else - { - /* Invalid Mode (black screen) */ - data = 0x00; - } - - /* Output pixel: x0xiiiii */ - /* Backdrop pixel: 01000000 */ - pixel_16[0x00 | index] = data; - pixel_16[0x20 | index] = data; - pixel_16[0x80 | index] = data; - pixel_16[0xA0 | index] = data; - } -} - -static void color_update_32(int index, unsigned int data) -{ - /* Mode 5 */ - if (reg[1] & 4) - { - /* VDP Palette Selection bit */ - if (!(reg[0] & 4)) - { - /* Color value is limited to 00X00X00X */ - data &= 0x49; - } - - if(reg[12] & 8) - { - /* Mode 5 (Shadow/Normal/Highlight) */ - pixel_32[0x00 | index] = pixel_32_lut[0][data]; - pixel_32[0x40 | index] = pixel_32_lut[1][data]; - pixel_32[0x80 | index] = pixel_32_lut[2][data]; - } - else - { - /* Mode 5 (Normal) */ - data = pixel_32_lut[1][data]; - - /* Output pixel: xxiiiiii */ - pixel_32[0x00 | index] = data; - pixel_32[0x40 | index] = data; - pixel_32[0x80 | index] = data; - } - } - else - { - /* Test M4 bit */ - if (reg[0] & 4) - { - /* Mode 4 */ - data = pixel_32_lut_m4[data & 0x3F]; - } - else - { - /* Invalid Mode (black screen) */ - data = 0x00; - } - - /* Output pixel: x0xiiiii */ - /* Backdrop pixel: 01000000 */ - pixel_32[0x00 | index] = data; - pixel_32[0x20 | index] = data; - pixel_32[0x80 | index] = data; - pixel_32[0xA0 | index] = data; - } -} - -#else - -void color_update(int index, unsigned int data) -{ - /* Mode 5 */ - if (reg[1] & 4) - { - /* Palette selection */ - if (!(reg[0] & 4)) - { - /* Color value is limited to 00X00X00X */ - data &= 0x49; - } - - if(reg[12] & 8) - { - /* Mode 5 (Shadow/Normal/Highlight) */ - pixel[0x00 | index] = pixel_lut[0][data]; - pixel[0x40 | index] = pixel_lut[1][data]; - pixel[0x80 | index] = pixel_lut[2][data]; - } - else - { - /* Mode 5 (Normal) */ - data = pixel_lut[1][data]; - - /* Output pixel: xxiiiiii */ - pixel[0x00 | index] = data; - pixel[0x40 | index] = data; - pixel[0x80 | index] = data; - } - } - else - { - /* Test M4 bit */ - if (reg[0] & 4) - { - /* Mode 4 */ + /* Mode 4 palette */ data = pixel_lut_m4[data & 0x3F]; + break; } - else - { - /* Invalid Mode (black screen) */ - data = 0x00; - } + } - /* Output pixel: x0xiiiii */ - /* Backdrop pixel: 01000000 */ + + /* Input pixel: x0xiiiii (normal) or 01000000 (backdrop) */ + if (reg[0] & 0x04) + { + /* Mode 4 */ pixel[0x00 | index] = data; pixel[0x20 | index] = data; pixel[0x80 | index] = data; pixel[0xA0 | index] = data; } + else + { + /* TMS9918 modes (palette bit forced to 1 because Game Gear uses CRAM palette #1) */ + if ((index == 0x40) || (index == (0x10 | (reg[7] & 0x0F)))) + { + /* Update backdrop color */ + pixel[0x40] = data; + + /* Update transparent color */ + pixel[0x10] = data; + pixel[0x30] = data; + pixel[0x90] = data; + pixel[0xB0] = data; + } + + if (index & 0x0F) + { + /* update non-transparent colors */ + pixel[0x00 | index] = data; + pixel[0x20 | index] = data; + pixel[0x80 | index] = data; + pixel[0xA0 | index] = data; + } + } } -#endif +void color_update_m5(int index, unsigned int data) +{ + /* Palette Mode */ + if (!(reg[0] & 0x04)) + { + /* Color value is limited to 00X00X00X */ + data &= 0x49; + } + if(reg[12] & 0x08) + { + /* Mode 5 (Shadow/Normal/Highlight) */ + pixel[0x00 | index] = pixel_lut[0][data]; + pixel[0x40 | index] = pixel_lut[1][data]; + pixel[0x80 | index] = pixel_lut[2][data]; + } + else + { + /* Mode 5 (Normal) */ + data = pixel_lut[1][data]; + + /* Input pixel: xxiiiiii */ + pixel[0x00 | index] = data; + pixel[0x40 | index] = data; + pixel[0x80 | index] = data; + } +} /*--------------------------------------------------------------------------*/ /* Background layers rendering functions */ /*--------------------------------------------------------------------------*/ +/* Graphics I */ +void render_bg_m0(int line, int width) +{ + uint8 color, pattern; + uint16 name; + + uint8 *lb = &linebuf[0][0x20]; + uint8 *nt = &vram[((reg[2] << 10) & 0x3C00) + ((line & 0xF8) << 2)]; + uint8 *ct = &vram[((reg[3] << 6) & 0x3FC0)]; + uint8 *pg = &vram[((reg[4] << 11) & 0x3800) + (line & 7)]; + + /* 32 x 8 pixels */ + width = 32; + + do + { + name = *nt++; + color = ct[name >> 3]; + pattern = pg[name << 3]; + + *lb++ = 0x10 | ((color >> (((pattern >> 7) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 6) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 5) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 4) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 3) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 2) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 1) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 0) & 1) << 2)) & 0x0F); + } + while (--width); +} + +/* Text */ +void render_bg_m1(int line, int width) +{ + uint8 pattern; + uint8 color = reg[7]; + + uint8 *lb = &linebuf[0][0x20]; + uint8 *nt = &vram[((reg[2] << 10) & 0x3C00) + ((line >> 3) * 40)]; + uint8 *pg = &vram[((reg[4] << 11) & 0x3800) + (line & 7)]; + + /* Left border (8 pixels) */ + memset (lb, 0x40, 8); + lb += 8; + + /* 40 x 6 pixels */ + width = 40; + + do + { + pattern = pg[*nt++]; + + *lb++ = 0x10 | ((color >> (((pattern >> 7) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 6) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 5) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 4) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 3) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 2) & 1) << 2)) & 0x0F); + } + while (--width); + + /* Right borders (8 pixels) */ + memset(lb, 0x40, 8); +} + +/* Text + extended PG */ +void render_bg_m1x(int line, int width) +{ + uint8 pattern; + uint8 color = reg[7]; + + uint16 pg_mask = ~0x3800 ^ (reg[4] << 11); + + /* Unused bits used as a mask on TMS9918 & 315-5124 VDP only */ + if (system_hw > SYSTEM_SMS) + { + pg_mask |= 0x1800; + } + + uint8 *lb = &linebuf[0][0x20]; + uint8 *nt = &vram[((reg[2] << 10) & 0x3C00) + ((line >> 3) * 40)]; + uint8 *pg = &vram[((0x2000 + ((line & 0xC0) << 5)) & pg_mask) + (line & 7)]; + + /* Left border (8 pixels) */ + memset (lb, 0x40, 8); + lb += 8; + + /* 40 x 6 pixels */ + width = 40; + + do + { + pattern = pg[*nt++ << 3]; + + *lb++ = 0x10 | ((color >> (((pattern >> 7) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 6) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 5) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 4) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 3) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 2) & 1) << 2)) & 0x0F); + } + while (--width); + + /* Right borders (8 pixels) */ + memset(lb, 0x40, 8); +} + +/* Graphics II */ +void render_bg_m2(int line, int width) +{ + uint8 color, pattern; + uint16 name; + + uint16 ct_mask = ~0x3FC0 ^ (reg[3] << 6); + uint16 pg_mask = ~0x3800 ^ (reg[4] << 11); + + /* Unused bits used as a mask on TMS9918 & 315-5124 VDP only */ + if (system_hw > SYSTEM_SMS) + { + ct_mask |= 0x1FC0; + pg_mask |= 0x1800; + } + + uint8 *lb = &linebuf[0][0x20]; + uint8 *nt = &vram[((reg[2] << 10) & 0x3C00) + ((line & 0xF8) << 2)]; + uint8 *ct = &vram[((0x2000 + ((line & 0xC0) << 5)) & ct_mask) + (line & 7)]; + uint8 *pg = &vram[((0x2000 + ((line & 0xC0) << 5)) & pg_mask) + (line & 7)]; + + /* 32 x 8 pixels */ + width = 32; + + do + { + name = *nt++ << 3 ; + color = ct[name & ct_mask]; + pattern = pg[name]; + + *lb++ = 0x10 | ((color >> (((pattern >> 7) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 6) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 5) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 4) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 3) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 2) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 1) & 1) << 2)) & 0x0F); + *lb++ = 0x10 | ((color >> (((pattern >> 0) & 1) << 2)) & 0x0F); + } + while (--width); +} + +/* Multicolor */ +void render_bg_m3(int line, int width) +{ + uint8 color; + uint16 name; + + uint8 *lb = &linebuf[0][0x20]; + uint8 *nt = &vram[((reg[2] << 10) & 0x3C00) + ((line & 0xF8) << 2)]; + uint8 *pg = &vram[((reg[4] << 11) & 0x3800) + ((line >> 2) & 7)]; + + /* 32 x 8 pixels */ + width = 32; + + do + { + name = *nt++; + color = pg[name << 3]; + + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + } + while (--width); +} + +/* Multicolor + extended PG */ +void render_bg_m3x(int line, int width) +{ + uint8 color; + uint16 name; + + uint16 pg_mask = ~0x3800 ^ (reg[4] << 11); + + /* Unused bits used as a mask on TMS9918 & 315-5124 VDP only */ + if (system_hw > SYSTEM_SMS) + { + pg_mask |= 0x1800; + } + + uint8 *lb = &linebuf[0][0x20]; + uint8 *nt = &vram[((reg[2] << 10) & 0x3C00) + ((line & 0xF8) << 2)]; + uint8 *pg = &vram[((0x2000 + ((line & 0xC0) << 5)) & pg_mask) + ((line >> 2) & 7)]; + + /* 32 x 8 pixels */ + width = 32; + + do + { + name = *nt++; + color = pg[name << 3]; + + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + } + while (--width); +} + +/* Invalid (2+3/1+2+3) */ +void render_bg_inv(int line, int width) +{ + uint8 color = reg[7]; + + uint8 *lb = &linebuf[0][0x20]; + + /* Left border (8 pixels) */ + memset (lb, 0x40, 8); + lb += 8; + + /* 40 x 6 pixels */ + width = 40; + + do + { + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 4) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + *lb++ = 0x10 | ((color >> 0) & 0x0F); + } + while (--width); + + /* Right borders (8 pixels) */ + memset(lb, 0x40, 8); +} + +/* Mode 4 */ void render_bg_m4(int line, int width) { int column; + uint16 *nt; uint32 attr, atex, *src; - + /* Horizontal scrolling */ - int index = ((reg[0] & 0x40) && (line < 0x10)) ? 0x100 : hscroll; + int index = ((reg[0] & 0x40) && (line < 0x10)) ? 0x100 : reg[0x08]; int shift = index & 7; /* Background line buffer */ uint32 *dst = (uint32 *)&linebuf[0][0x20 + shift]; - /* Vertical scrolling */ - int v_line = (line + vscroll) % 224; + /* Pattern name table mask */ + uint16 nt_mask = ~0x3C00 ^ (reg[2] << 10); - /* Pattern name table */ - uint16 *nt = (uint16 *)&vram[((reg[2] << 10) & 0x3800) + ((v_line >> 3) << 6)]; + /* Unused bits used as a mask on TMS9918 & 315-5124 VDP only */ + if (system_hw > SYSTEM_SMS) + { + nt_mask |= 0x400; + } + + /* Vertical scrolling */ + int v_line = line + vscroll; + + /* Test for extended modes (Master System II & Game gear VDP only) */ + if (bitmap.viewport.h > 192) + { + /* Vertical scroll mask */ + v_line = v_line % 256; + + /* Pattern name Table */ + nt = (uint16 *)&vram[(0x3700 & nt_mask) + ((v_line >> 3) << 6)]; + } + else + { + /* Vertical scroll mask */ + v_line = v_line % 224; + + /* Pattern name Table */ + nt = (uint16 *)&vram[(0x3800 + ((v_line >> 3) << 6)) & nt_mask]; + } /* Pattern row index */ v_line = (v_line & 7) << 3; @@ -1273,14 +1444,21 @@ void render_bg_m4(int line, int width) /* Number of tiles to draw */ width >>= 3; - /* Draw tiles (TODO: test what happens when H40 mode has been set while in Mode 5 */ + /* Draw tiles */ for(column = 0; column < width; column++, index++) { /* Stop vertical scrolling for rightmost eight tiles */ if((column == 24) && (reg[0] & 0x80)) { - /* Clear name table base */ - nt = (uint16 *)&vram[((reg[2] << 10) & 0x3800) + ((line >> 3) << 6)]; + /* Clear Pattern name table start address */ + if (bitmap.viewport.h > 192) + { + nt = (uint16 *)&vram[(0x3700 & nt_mask) + ((line >> 3) << 6)]; + } + else + { + nt = (uint16 *)&vram[(0x3800 + ((line >> 3) << 6)) & nt_mask]; + } /* Clear Pattern row index */ v_line = (line & 7) << 3; @@ -1309,11 +1487,9 @@ void render_bg_m4(int line, int width) *dst++ = (src[1] | atex); #endif } - - /* latch horizontal scroll value */ - hscroll = reg[0x08]; } +/* Mode 5 */ #ifndef ALT_RENDERER void render_bg_m5(int line, int width) { @@ -2698,19 +2874,178 @@ void render_bg_m5_im2_vs(int line, int width) /* Sprite layer rendering functions */ /*--------------------------------------------------------------------------*/ -void render_obj_m4(int max_width) +void render_obj_tms(int max_width) { - int i, count, xpos, width; - uint8 *src, *lb; + int x, count, start, end; + uint8 *lb, *sg; + uint8 color, pattern[2]; uint16 temp; + /* Default sprite width (8 pixels) */ + int width = 8; + + /* Adjust width for 16x16 sprites */ + width <<= ((reg[1] & 0x02) >> 1); + + /* Adjust width for zoomed sprites */ + width <<= (reg[1] & 0x01); + /* Set SOVR flag */ - status |= spr_over; - spr_over = 0; + status |= spr_ovr; + spr_ovr = 0; /* Draw sprites in front-to-back order */ for (count = 0; count < object_count; count++) { + /* Sprite X position */ + start = object_info[count].xpos; + + /* Sprite Color + Early Clock bit */ + color = object_info[count].size; + + /* X position shift (32 pixels) */ + start -= ((color & 0x80) >> 2); + + /* Pointer to line buffer */ + lb = &linebuf[0][0x20 + start]; + + if ((start + width) > 256) + { + /* Clip sprites on right edge */ + end = 256 - start; + + start = 0; + } + else + { + end = width; + + if (start < 0) + { + /* Clip sprites on left edge */ + start = 0 - start; + } + else + { + start = 0; + } + } + + /* Sprite Color (0-15) */ + color &= 0x0F; + + /* Sprite Pattern Name */ + temp = object_info[count].attr; + + /* Mask two LSB for 16x16 sprites */ + temp &= ~((reg[1] & 0x02) >> 0); + temp &= ~((reg[1] & 0x02) >> 1); + + /* Pointer to sprite generator table */ + sg = (uint8 *)&vram[((reg[6] << 11) & 0x3800) | (temp << 3) | object_info[count].ypos]; + + /* Sprite Pattern data (2 x 8 pixels) */ + pattern[0] = sg[0x00]; + pattern[1] = sg[0x10]; + + if (reg[1] & 0x01) + { + /* Zoomed sprites are rendered at half speed */ + for (x=start; x> 4) & 1]; + temp = (temp >> (7 - ((x >> 1) & 7))) & 0x01; + temp = temp * color; + temp |= (lb[x] << 8); + lb[x] = lut[5][temp]; + status |= ((temp & 0x8000) >> 10); + temp &= 0x00FF; + temp |= (lb[x+1] << 8); + lb[x+1] = lut[5][temp]; + status |= ((temp & 0x8000) >> 10); + } + } + else + { + /* Normal sprites */ + for (x=start; x> 3) & 1]; + temp = (temp >> (7 - (x & 7))) & 0x01; + temp = temp * color; + temp |= (lb[x] << 8); + lb[x] = lut[5][temp]; + status |= ((temp & 0x8000) >> 10); + } + } + } + + /* handle Game Gear reduced screen (160x144) */ + if ((system_hw == SYSTEM_GG) && (v_counter < bitmap.viewport.h)) + { + int line = v_counter - (bitmap.viewport.h - 144) / 2; + if ((line < 0) || (line >= 144)) + { + memset(&linebuf[0][0x20], 0x40, max_width); + } + else + { + if (bitmap.viewport.x > 0) + { + memset(&linebuf[0][0x20], 0x40, 48); + memset(&linebuf[0][0x20+48+160], 0x40, 48); + } + } + } +} + +void render_obj_m4(int max_width) +{ + int i, count, xpos, end; + uint8 *src, *lb; + uint16 temp; + + /* Default sprite width */ + int width = 8; + + /* Zoomed sprites (not working on Genesis VDP) */ + if (system_hw < SYSTEM_MD) + { + width <<= (reg[1] & 0x01); + } + + /* Sprite Generator address mask (LSB is masked for 8x16 sprites) */ + uint16 sg_mask = (~0x1C0 ^ (reg[6] << 6)) & (~((reg[1] & 0x02) >> 1)); + + /* Unused bits used as a mask on 315-5124 VDP only */ + if (system_hw > SYSTEM_SMS) + { + sg_mask |= 0xC0; + } + + /* Set SOVR flag */ + status |= spr_ovr; + spr_ovr = 0; + + /* Draw sprites in front-to-back order */ + for (count = 0; count < object_count; count++) + { + /* 315-5124 VDP specific */ + if (count == 4) + { + if (system_hw < SYSTEM_SMS2) + { + /* Only 4 first sprites can be zoomed */ + width = 8; + } + } + + /* Sprite pattern index */ + temp = (object_info[count].attr | 0x100) & sg_mask; + + /* Pointer to pattern cache line */ + src = (uint8 *)&bg_pattern_cache[(temp << 6) | (object_info[count].ypos << 3)]; + /* Sprite X position */ xpos = object_info[count].xpos; @@ -2720,37 +3055,52 @@ void render_obj_m4(int max_width) if (xpos < 0) { /* Clip sprites on left edge */ - width = xpos + 8; + src = src - xpos; + end = xpos + width; xpos = 0; } - else if ((xpos + 8) > max_width) + else if ((xpos + width) > max_width) { /* Clip sprites on right edge */ - width = max_width - xpos; + end = max_width - xpos; } else { - /* Sprite default width */ - width = 8; + /* Sprite maximal width */ + end = width; } /* Pointer to line buffer */ lb = &linebuf[0][0x20 + xpos]; - /* Sprite pattern index */ - temp = object_info[count].attr; + if (width > 8) + { + /* Draw sprite pattern (zoomed sprites are rendered at half speed) */ + DRAW_SPRITE_TILE_ACCURATE_2X(end,0,lut[5]) + } + else + { + /* Draw sprite pattern */ + DRAW_SPRITE_TILE_ACCURATE(end,0,lut[5]) + } + } - /* Add MSB of pattern name */ - temp |= ((reg[6] & 0x04) << 6); - - /* Mask LSB for 8x16 sprites */ - temp &= ~((reg[1] & 0x02) >> 1); - - /* Pointer to pattern cache line */ - src = (uint8 *)&bg_pattern_cache[(temp << 6) | (object_info[count].ypos << 3)]; - - /* Draw sprite pattern */ - DRAW_SPRITE_TILE(width,0,lut[5]) + /* handle Game Gear reduced screen (160x144) */ + if ((system_hw == SYSTEM_GG) && (v_counter < bitmap.viewport.h)) + { + int line = v_counter - (bitmap.viewport.h - 144) / 2; + if ((line < 0) || (line >= 144)) + { + memset(&linebuf[0][0x20], 0x40, max_width); + } + else + { + if (bitmap.viewport.x > 0) + { + memset(&linebuf[0][0x20], 0x40, 48); + memset(&linebuf[0][0x20+48+160], 0x40, 48); + } + } } } @@ -2780,9 +3130,9 @@ void render_obj_m5(int max_width) if (xpos) { /* Requires at least one sprite with xpos > 0 */ - spr_over = 1; + spr_ovr = 1; } - else if (spr_over) + else if (spr_ovr) { /* Remaining sprites are not drawn */ masked = 1; @@ -2849,7 +3199,7 @@ void render_obj_m5(int max_width) if (pixelcount >= max_width) { /* Sprite masking will be effective on next line */ - spr_over = 1; + spr_ovr = 1; /* Stop sprite rendering */ return; @@ -2857,7 +3207,7 @@ void render_obj_m5(int max_width) } /* Clear sprite masking for next line */ - spr_over = 0; + spr_ovr = 0; } void render_obj_m5_ste(int max_width) @@ -2889,9 +3239,9 @@ void render_obj_m5_ste(int max_width) if (xpos) { /* Requires at least one sprite with xpos > 0 */ - spr_over = 1; + spr_ovr = 1; } - else if (spr_over) + else if (spr_ovr) { /* Remaining sprites are not drawn */ masked = 1; @@ -2958,7 +3308,7 @@ void render_obj_m5_ste(int max_width) if (pixelcount >= max_width) { /* Sprite masking will be effective on next line */ - spr_over = 1; + spr_ovr = 1; /* Merge background & sprite layers */ merge(&linebuf[1][0x20],&linebuf[0][0x20],&linebuf[0][0x20],lut[4], max_width); @@ -2969,7 +3319,7 @@ void render_obj_m5_ste(int max_width) } /* Clear sprite masking for next line */ - spr_over = 0; + spr_ovr = 0; /* Merge background & sprite layers */ merge(&linebuf[1][0x20],&linebuf[0][0x20],&linebuf[0][0x20],lut[4], max_width); @@ -3002,9 +3352,9 @@ void render_obj_m5_im2(int max_width) if (xpos) { /* Requires at least one sprite with xpos > 0 */ - spr_over = 1; + spr_ovr = 1; } - else if (spr_over) + else if (spr_ovr) { /* Remaining sprites are not drawn */ masked = 1; @@ -3071,7 +3421,7 @@ void render_obj_m5_im2(int max_width) if (pixelcount >= max_width) { /* Enable sprite masking for next line */ - spr_over = 1; + spr_ovr = 1; /* Stop sprite rendering */ return; @@ -3079,7 +3429,7 @@ void render_obj_m5_im2(int max_width) } /* Clear sprite masking for next line */ - spr_over = 0; + spr_ovr = 0; } void render_obj_m5_im2_ste(int max_width) @@ -3112,9 +3462,9 @@ void render_obj_m5_im2_ste(int max_width) if (xpos) { /* Requires at least one sprite with xpos > 0 */ - spr_over = 1; + spr_ovr = 1; } - else if (spr_over) + else if (spr_ovr) { /* Remaining sprites are not drawn */ masked = 1; @@ -3181,7 +3531,7 @@ void render_obj_m5_im2_ste(int max_width) if (pixelcount >= max_width) { /* Enable sprite masking for next line */ - spr_over = 1; + spr_ovr = 1; /* Merge background & sprite layers */ merge(&linebuf[1][0x20],&linebuf[0][0x20],&linebuf[0][0x20],lut[4], max_width); @@ -3192,7 +3542,7 @@ void render_obj_m5_im2_ste(int max_width) } /* Clear sprite masking for next line */ - spr_over = 0; + spr_ovr = 0; /* Merge background & sprite layers */ merge(&linebuf[1][0x20],&linebuf[0][0x20],&linebuf[0][0x20],lut[4], max_width); @@ -3203,14 +3553,97 @@ void render_obj_m5_im2_ste(int max_width) /* Sprites Parsing functions */ /*--------------------------------------------------------------------------*/ -void parse_satb_m4(int line) +void parse_satb_tms(int line) { - int i; + if (reg[1] & 0x10) + { + /* no sprites in Text modes */ + object_count = 0; + return; + } + + int i = 0; /* Pointer to sprite attribute table */ - uint8 *st = &vram[(reg[5] << 7) & 0x3F00]; + uint8 *st = &vram[(reg[5] << 7) & 0x3F80]; - /* Sprite counter (64 max.) */ + /* Sprite counter (4 max. per line) */ + int count = 0; + + /* Y position */ + int ypos; + + /* Sprite height (8 pixels by default) */ + int height = 8; + + /* Adjust height for 16x16 sprites */ + height <<= ((reg[1] & 0x02) >> 1); + + /* Adjust height for zoomed sprites */ + height <<= (reg[1] & 0x01); + + /* Parse Sprite Table (32 entries) */ + do + { + /* Sprite Y position */ + ypos = st[i << 2]; + + /* Check end of sprite list marker */ + if (ypos == 0xD0) + { + break; + } + + /* Wrap Y coordinate for sprites > 256-32 */ + if (ypos >= 224) + { + ypos -= 256; + } + + /* Y range */ + ypos = line - ypos; + + /* Sprite is visble on this line ? */ + if ((ypos >= 0) && (ypos < height)) + { + /* Sprite overflow */ + if (count == 4) + { + /* Flag is set only during active area */ + if (line < bitmap.viewport.h) + { + spr_ovr = 0x40; + } + break; + } + + /* Adjust Y range back for zoomed sprites */ + ypos >>= (reg[1] & 0x01); + + /* Store sprite attributes for later processing */ + object_info[count].ypos = ypos; + object_info[count].xpos = st[(i << 2) + 1]; + object_info[count].attr = st[(i << 2) + 2]; + object_info[count].size = st[(i << 2) + 3]; + + /* Increment Sprite count */ + ++count; + } + } + while (++i < 32); + + /* Update sprite count for next line */ + object_count = count; + + /* Insert number of last sprite entry processed */ + status = (status & 0xE0) | (i & 0x1F); +} + +void parse_satb_m4(int line) +{ + int i = 0; + + /* Sprite counter (8 max. per line) */ int count = 0; /* Y position */ @@ -3222,20 +3655,32 @@ void parse_satb_m4(int line) /* Adjust height for 8x16 sprites */ height <<= ((reg[1] & 0x02) >> 1); + /* Sprite attribute table address mask */ + uint16 st_mask = ~0x3F80 ^ (reg[5] << 7); + + /* Unused bits used as a mask on 315-5124 VDP only */ + if (system_hw > SYSTEM_SMS) + { + st_mask |= 0x80; + } + + /* Pointer to sprite attribute table */ + uint8 *st = &vram[st_mask & 0x3F00]; + /* Parse Sprite Table (64 entries) */ - for(i = 0; i < 64; i++) + do { /* Sprite Y position */ ypos = st[i]; - /* Found end of sprite list marker for non-extended modes? */ - if(ypos == 208) + /* Check end of sprite list marker */ + if(ypos == (bitmap.viewport.h + 16)) { break; } - /* Wrap Y coordinate for sprites > 240 */ - if(ypos > 240) + /* Wrap Y coordinate for sprites > 256-16 */ + if (ypos >= 240) { ypos -= 256; } @@ -3243,25 +3688,36 @@ void parse_satb_m4(int line) /* Y range */ ypos = line - ypos; - /* Sprite is visble on this line ? */ - if((ypos >= 0) && (ypos < height)) + /* Adjust Y range for zoomed sprites (not working on Mega Drive VDP) */ + if (system_hw < SYSTEM_MD) + { + ypos >>= (reg[1] & 0x01); + } + + /* Check if sprite is visible on this line */ + if ((ypos >= 0) && (ypos < height)) { /* Sprite overflow */ - if(count == 8) + if (count == 8) { - spr_over = 0x40; + /* Flag is set only during active area */ + if ((line >= 0) && (line < bitmap.viewport.h)) + { + spr_ovr = 0x40; + } break; } /* Store sprite attributes for later processing */ object_info[count].ypos = ypos; - object_info[count].xpos = st[0x80 + (i << 1)]; - object_info[count].attr = st[0x81 + (i << 1)]; + object_info[count].xpos = st[(0x80 + (i << 1)) & st_mask]; + object_info[count].attr = st[(0x81 + (i << 1)) & st_mask]; /* Increment Sprite count */ ++count; } } + while (++i < 64); /* Update sprite count for next line */ object_count = count; @@ -3315,7 +3771,7 @@ void parse_satb_m5(int line) if ((ypos >= 0) && (ypos < height)) { /* Sprite overflow */ - if(count == max) + if (count == max) { status |= 0x40; break; @@ -3334,7 +3790,7 @@ void parse_satb_m5(int line) link = (q[link + 1] & 0x7F) << 2; /* Last sprite */ - if(link == 0) break; + if (link == 0) break; } while (--total); @@ -3462,7 +3918,7 @@ void update_bg_pattern_cache_m5(int index) /*--------------------------------------------------------------------------*/ -/* Window & Plane A clipping update function */ +/* Window & Plane A clipping update function (Mode 5) */ /*--------------------------------------------------------------------------*/ void window_clip(unsigned int data, unsigned int sw) @@ -3526,30 +3982,19 @@ void render_init(void) { index = (bx << 8) | (ax); - lut[0][index] = make_lut_bg (bx, ax); - lut[1][index] = make_lut_bgobj (bx, ax); - lut[2][index] = make_lut_bg_ste (bx, ax); - lut[3][index] = make_lut_obj (bx, ax); - lut[4][index] = make_lut_bgobj_ste (bx, ax); - lut[5][index] = make_lut_bgobj_m4 (bx,ax); + lut[0][index] = make_lut_bg(bx, ax); + lut[1][index] = make_lut_bgobj(bx, ax); + lut[2][index] = make_lut_bg_ste(bx, ax); + lut[3][index] = make_lut_obj(bx, ax); + lut[4][index] = make_lut_bgobj_ste(bx, ax); + lut[5][index] = make_lut_bgobj_m4(bx,ax); } } /* Initialize pixel color look-up tables */ palette_init(); -#ifndef NGC - /* Set default color palette update function */ - switch(bitmap.depth) - { - case 8: color_update = color_update_8; break; - case 15: color_update = color_update_15; break; - case 16: color_update = color_update_16; break; - case 32: color_update = color_update_32; break; - } -#endif - - /* Make sprite pattern name index look-up table */ + /* Make sprite pattern name index look-up table (Mode 5) */ make_name_lut(); /* Make bitplane to pixel look-up table (Mode 4) */ @@ -3565,14 +4010,10 @@ void render_reset(void) memset(linebuf, 0, sizeof(linebuf)); /* Clear color palettes */ -#ifdef NGC - memset(&pixel, 0, sizeof(pixel)); -#else - memset(&pixel_8, 0, sizeof(pixel_8)); - memset(&pixel_15, 0, sizeof(pixel_15)); - memset(&pixel_16, 0, sizeof(pixel_16)); - memset(&pixel_32, 0, sizeof(pixel_32)); -#endif + memset(pixel, 0, sizeof(pixel)); + + /* Reset Sprite infos */ + spr_ovr = spr_col = object_count = 0; } @@ -3583,7 +4024,6 @@ void render_reset(void) void render_line(int line) { int width = bitmap.viewport.w; - int x_offset = bitmap.viewport.x; /* Check display status */ if (reg[1] & 0x40) @@ -3602,16 +4042,12 @@ void render_line(int line) render_obj(width); /* Left-most column blanking */ - if(reg[0] & 0x20) + if (reg[0] & 0x20) { - memset(&linebuf[0][0x20], 0x40, 8); - } - - /* Horizontal borders */ - if (x_offset) - { - memset(&linebuf[0][0x20 - x_offset], 0x40, x_offset); - memset(&linebuf[0][0x20 + width], 0x40, x_offset); + if (system_hw > SYSTEM_SG) + { + memset(&linebuf[0][0x20], 0x40, 8); + } } /* Parse sprites for next line */ @@ -3622,8 +4058,27 @@ void render_line(int line) } else { - /* Display disabled */ - memset(&linebuf[0][0x20 - x_offset], 0x40, width + (x_offset << 1)); + /* Master System & Game Gear VDP specific */ + if (system_hw < SYSTEM_MD) + { + /* Update SOVR flag */ + status |= spr_ovr; + spr_ovr = 0; + + /* Sprites are still parsed when display is disabled */ + parse_satb(line); + } + + /* Blanked line */ + memset(&linebuf[0][0x20], 0x40, width); + } + + /* Horizontal borders */ + int x_offset = bitmap.viewport.x; + if (x_offset > 0) + { + memset(&linebuf[0][0x20 - x_offset], 0x40, x_offset); + memset(&linebuf[0][0x20 + width], 0x40, x_offset); } /* Pixel color remapping */ @@ -3640,37 +4095,45 @@ void remap_line(int line) { /* Line width */ int x_offset = bitmap.viewport.x; - int width = bitmap.viewport.w + (x_offset << 1); + int width = bitmap.viewport.w + (x_offset * 2); /* Adjust line offset in framebuffer */ line = (line + bitmap.viewport.y) % lines_per_frame; + /* Take care of Game Gear reduced screen when overscan is disabled */ + if (line < 0) return; + /* Adjust for interlaced output */ if (interlaced && config.render) { - line = (line << 1) + odd_frame; + line = (line * 2) + odd_frame; } -#ifdef NGC - /* NTSC Filter */ + /* Pixel line buffer */ + uint8 *src = &linebuf[0][0x20 - x_offset]; + + /* NTSC Filter (only supported for 16-bit pixels rendering) */ +#ifdef USE_16BPP_RENDERING if (config.ntsc) { - if (reg[12]&1) + if (reg[12] & 0x01) { - md_ntsc_blit(md_ntsc, ( MD_NTSC_IN_T const * )pixel, &linebuf[0][0x20 - x_offset], width, line); + md_ntsc_blit(md_ntsc, ( MD_NTSC_IN_T const * )pixel, src, width, line); } else { - sms_ntsc_blit(sms_ntsc, ( SMS_NTSC_IN_T const * )pixel, &linebuf[0][0x20 - x_offset], width, line); + sms_ntsc_blit(sms_ntsc, ( SMS_NTSC_IN_T const * )pixel, src, width, line); } } else +#endif { + /* Convert VDP pixel data to output pixel format */ +#ifdef NGC /* Directly fill a RGB565 texture */ /* One tile is 32 byte = 4x4 pixels */ /* Tiles are stored continuously in texture memory */ width >>= 2; - uint8 *src = &linebuf[0][0x20 - x_offset]; uint16 *dst = (uint16 *) (texturemem + (((width << 5) * (line >> 2)) + ((line & 3) << 3))); do { @@ -3683,23 +4146,19 @@ void remap_line(int line) dst += 12; } while (--width); - } #else - void *out =((void *)&bitmap.data[(line * bitmap.pitch)]); - switch(bitmap.depth) - { - case 8: - remap_8(&linebuf[0][0x20 - x_offset], (uint8 *)out, width); - break; - case 15: - remap_16(&linebuf[0][0x20 - x_offset], (uint16 *)out, width); - break; - case 16: - remap_16(&linebuf[0][0x20 - x_offset], (uint16 *)out, width); - break; - case 32: - remap_32(&linebuf[0][0x20 - x_offset], (uint32 *)out, width); - break; - } +#if defined(USE_8BPP_RENDERING) + uint8 *dst =((uint8 *)&bitmap.data[(line * bitmap.pitch)]); +#elif defined(USE_32BPP_RENDERING) + uint32 *dst =((uint32 *)&bitmap.data[(line * bitmap.pitch)]); +#else + uint16 *dst =((uint16 *)&bitmap.data[(line * bitmap.pitch)]); #endif + do + { + *dst++ = pixel[*src++]; + } + while (--width); +#endif + } } diff --git a/source/vdp_render.h b/source/vdp_render.h index 7d77383..5c1d410 100644 --- a/source/vdp_render.h +++ b/source/vdp_render.h @@ -1,23 +1,41 @@ /*************************************************************************************** * Genesis Plus - * Video Display Processor (Mode 4 & Mode 5 rendering) + * Video Display Processor (Modes 0, 1, 2, 3, 4 & 5 rendering) * - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code) - * Eke-Eke (2007-2011), additional code & fixes for the GCN/Wii port + * Support for SG-1000, Master System (315-5124 & 315-5246), Game Gear & Mega Drive VDP * - * 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. + * Copyright (C) 1998-2007 Charles Mac Donald (original code) + * Copyright (C) 2007-2011 Eke-Eke (Genesis Plus GX) * - * 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. + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: * - * 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 + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************************/ @@ -26,6 +44,7 @@ /* Global variables */ extern uint8 object_count; +extern uint16 spr_col; /* Function prototypes */ extern void render_init(void); @@ -34,32 +53,37 @@ extern void render_line(int line); extern void blank_line(int line, int offset, int width); extern void remap_line(int line); extern void window_clip(unsigned int data, unsigned int sw); +extern void render_bg_m0(int line, int width); +extern void render_bg_m1(int line, int width); +extern void render_bg_m1x(int line, int width); +extern void render_bg_m2(int line, int width); +extern void render_bg_m3(int line, int width); +extern void render_bg_m3x(int line, int width); +extern void render_bg_inv(int line, int width); extern void render_bg_m4(int line, int width); extern void render_bg_m5(int line, int width); extern void render_bg_m5_vs(int line, int width); extern void render_bg_m5_im2(int line, int width); extern void render_bg_m5_im2_vs(int line, int width); +extern void render_obj_tms(int max_width); extern void render_obj_m4(int max_width); extern void render_obj_m5(int max_width); extern void render_obj_m5_ste(int max_width); extern void render_obj_m5_im2(int max_width); extern void render_obj_m5_im2_ste(int max_width); +extern void parse_satb_tms(int line); extern void parse_satb_m4(int line); extern void parse_satb_m5(int line); extern void update_bg_pattern_cache_m4(int index); extern void update_bg_pattern_cache_m5(int index); -#ifdef NGC -extern void color_update(int index, unsigned int data); -#endif +extern void color_update_m4(int index, unsigned int data); +extern void color_update_m5(int index, unsigned int data); /* Function pointers */ extern void (*render_bg)(int line, int width); extern void (*render_obj)(int max_width); extern void (*parse_satb)(int line); extern void (*update_bg_pattern_cache)(int index); -#ifndef NGC -extern void (*color_update)(int index, unsigned int data); -#endif #endif /* _RENDER_H_ */ diff --git a/HISTORY.txt b/source/win/CHANGELOG.txt similarity index 57% rename from HISTORY.txt rename to source/win/CHANGELOG.txt index 3d25f19..f2b3190 100644 --- a/HISTORY.txt +++ b/source/win/CHANGELOG.txt @@ -1,5 +1,71 @@ +-------------------- +Genesis Plus History +-------------------- + +All recent changes were backported from the GX version (Gamecube/Wii port), maintained by Eke-Eke. +Please look at http://code.google.com/p/genplus-gx/ for more infos. + + --------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.5.0 (31/03/2011) (Eke-Eke) +[07/08/2011] version 1.6.0 (Eke-Eke) +--------------------------------------------------------------------------------------------------------- + +[Core/Sound] +--------------- +* added YM2413 emulation in Master System compatibility mode. +* fixed SN76489 noise boost initialization. +* minor YM2612 core optimizations. + +[Core/VDP] +--------------- +* added accurate emulation of SG-1000, Master System (315-5124, 315-5246) & Game Gear VDP. +* added support for all TMS9918 rendering modes. +* improved Mega Drive VDP timings accuracy in Master System Compatibility mode. +* fixed color palette initialization. +* fixed shifted sprites rendering in Mode 4. +* modified pixel rendering support (pixel depth is now forced at compilation time). + +[Core/CPU] +--------------- +* optimized 68k core (rewrote 68k interrupt handling, removed multiple CPU types support & unused code) for 5~8% speed improvment + +[Core/IO] +--------------- +* added accurate emulation of Master System (315-5216, 315-5237, 315-5297) & Game Gear I/O controllers. +* added Terebi Oekaki tablet emulation. +* improved Mouse emulation (fixes mouse support in Cannon Fodder). +* improved Justifier emulation (fixes gun support in Lethal Enforcers 2). +* improved 6-Buttons control pad emulation (fixes Duke Nukem 3D) +* modified lightgun emulation to use common key inputs for all devices. +* 2-buttons controller is now picked by default for Master System games. + +[Core/MD] +--------------- +* added copy-protection hardware emulation for some new dumped games (Tiny Toon Adventures 3, Mighty Morphin Power Rangers & The Battle of Red Cliffs). +* added Game Toshokan in EEPROM database (verified on real cartridge). +* fixed Micro Machines 2 - Turbo Tournament EEPROM size (verified on real cartridge). +* modified SRAM banswitch hardware emulation to be more compatible with some hacks. + +[Core/MS] +--------------- +* added Cyborg Z to Korean mapper database. + +[Core/GG] +--------------- +* added 93C46 EEPROM emulation (Majors Pro Baseball, World Series Baseball & World Series Baseball 95). + +[Core/General] +--------------- +* added support for .mdx ROM format. +* added Game Gear & SG-1000 ROM support. +* added accurate emulation of SG-1000, Master System (I, II) & Game Gear hardware models for 100% compatibility. +* updated to new Genesis Plus license (see http://cgfm2.emuviews.com/) +* removed DOS port +* various code cleanup. + + +--------------------------------------------------------------------------------------------------------- +[31/03/2011] version 1.5.0 (Eke-Eke) --------------------------------------------------------------------------------------------------------- [Core/VDP] @@ -31,26 +97,18 @@ Genesis Plus GX 1.5.0 (31/03/2011) (Eke-Eke) * improved savestate stability & compatibility (support for old 1.4.x savestates is preserved) * various code cleanup & comments. -[Gamecube/Wii] ---------------- -* fixed cheat codes handling when several codes affect same ROM address. -* improved input controller detection on menu exit. -* improved key remapping dialog box to match emulated device -* changed Menu key for Gamecube controller to allow MODE button mapping -* fixed DVD not being unmounted on swap (memory leak) - -[Wii only] ---------------- -* added USB mouse support for Sega Mouse emulation -* compiled with latest libogc: improves USB compatibility & fixes stability issues with Wiimotes. - --------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.4.1 (04/12/2010) (Eke-Eke) +[04/12/2010] version 1.4.1 (Eke-Eke) --------------------------------------------------------------------------------------------------------- +[Core/Sound] +--------------- +* implemented Blargg's blip buffer in SN76489 core (all channels are now lineary interpolated) + [Core/VDP] --------------- +* improved 2-cell vscroll emulation accuracy, as verified on real hardware (Gynoug, Cutie Suzuki no Ringside Angel, Formula One, Kawasaki Superbike Challenge) * improved VBLANK flag accuracy, as observed on real hardware. * improved DMA operations accuracy, writes are now performed on a scanline basis: fixes Gaiares (flickering title screen). * improved DMA Fill timing accuracy. @@ -60,8 +118,15 @@ Genesis Plus GX 1.4.1 (04/12/2010) (Eke-Eke) * fixed horizontal border width, as observed on real hardware. * various code improvments & optimizations. +[Core/CPU] +--------------- +* fixed state of Z80 registers on reset (sound issues with Defender & Defender 2 in Williams Arcade Classics) +* implemented 68k undocumented flags behavior for DIVU/DIVS instructions (Bloodshot / Battle Frenzy) + [Core/Extra] --------------- +* improved emulation of copy-protection hardware found in some unlicensed cartridges (Mulan, Pocket Monsters II). +* enabled simultaneous use of multitap & J-CART (Super Skidmarks 6-player mode) * improved savestate format: added DMA, SVP, cartridge mapping & internal registers state informations * improved unlicensed ROM mappers emulation * added Chinese Fighters III mapper support @@ -70,37 +135,13 @@ Genesis Plus GX 1.4.1 (04/12/2010) (Eke-Eke) * fixed cartridge hardware soft-reset (Game Genie, SVP, ...) * fixed Game Genie registers byte reads -[Gamecube/Wii] ---------------- -* added message box when inputs config uses disconnected controllers. -* added message box when settings are reseted to default on startup. -* fixed default inputs configuration. -* fixed memory leak in Cheat Menu causing spurious resets. -* added an option to enable/disable automatic cheat activation -* increased max number of cheat codes -* optimized cheat codes requiring RAM patching. -* improved default horizontal scaling to better match output from a real Mega Drive -[Gamecube specific] ---------------- -* fixed inverted keys in cheat menu. -* fixed audio input frequency, now use exact audio hardware samplerate, as measured on my Game Cube (~48044 Hz), - (NB: Wii samplerate has been verified to be closer to 48000 Hz) - -[Wii specific] ---------------- -* added the possibility for any wiimotes to be used as input device, regardless of the connected expansion controller. -* fixed USB drive not being detected when application is loaded from USB (HBC), thanks to Tantric for the tips. - - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.4.0 (01/11/2010) (Eke-Eke) ---------------------------------------------------------------------------------------------------------- +---------------------------------------------------------------------------------------------------------------------------------------------------- +[06/30/10] version 1.4.0 (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- [Core/Sound] ---------------- + * completely rewrote sound processing/mixing: sound chips are now clocked with exact output framerate to ensure 100% smooth video & audio playback, with no lag or skipping, while rendering an accurate number of samples per frame and keeping PSG & FM chips in sync. @@ -117,16 +158,15 @@ of samples per frame and keeping PSG & FM chips in sync. * added configurable 3-Band Equalizer (thanks to Neil C). * added an option to boost SN76489 Noise Channel. * adjusted SN76489 cut-off frequency. -* implemented Blargg's blip buffer in SN76489 core (all channels are now lineary interpolated) + [Core/VDP] ---------------- + * added support for CRAM writes during horizontal blanking (Striker, Zero the Kamikaze Squirrel,...) * added support for 2-Cell vertical scrolling in Interlaced 2 mode * added support for some undocumented mode register bits * added proper emulation of HV Counter latch: fixes Sunset Riders intro * added pixel-accurate emulation of mid-line display on/off (Nigel Mansell World Championship PAL, Ren & Stimpy's Invention PAL,...) -* improved 2-cell vscroll emulation accuracy, as verified on real hardware (Gynoug, Cutie Suzuki no Ringside Angel, Formula One, Kawasaki Superbike Challenge) * improved FIFO timings accuracy: fixes Sol Deace intro * improved sprite masking accuracy (thanks to Nemesis for his test program) * improved sprites processing accuracy: fixes (un)masked sprites in Mickey Mania (3D level), Sonic 2 (VS mode). @@ -135,71 +175,34 @@ of samples per frame and keeping PSG & FM chips in sync. * improved HCounter accuracy in 40-cell mode, as measured on real hardware. * improved color accuracy in VDP highlight mode to match results observed on real hardware + [Core/CPU] ---------------- + * updated Z80 core to last version (fixes interrupt Mode 0 timing and some BIT instructions). * fixed some Z80 instructions timing. -* fixed state of Z80 registers on reset (sound issues with Defender & Defender 2 in Williams Arcade Classics) * improved Z80 interrupt accuracy * improved 68k accuracy (initial Reset timing + auto-vectored interrupts handling). * improved 68k timing accuracy for DIVU/DVIS (thanks to Jorge Cwik) & MULU/MULS instructions. -* implemented 68k undocumented flags behavior for DIVU/DIVS instructions (Bloodshot / Battle Frenzy) * improved Z80 & 68k cpu execution/synchronization accuracy by using Master Clock as common reference (now run exactly 3420 M-Cycles per line). * modified Z80 & 68k cores to directly use external cycle count instead of intermediate counters. + [Core/Extra] ---------------- -* added Game Genie hardware emulation. -* added Action Replay & Pro Action Replay hardware emulation (only preliminary Pro Action Replay 2 support). -* added Sonic & Knuckles "Lock-On" support. -* added Cartridge "Hot Swap" feature. -* added missing EEPROM support in more games. -* added VDP lock-out emulation (TMSS). -* improved emulation of copy-protection hardware found in some unlicensed cartridges (Mulan, Pocket Monsters II). + +* added Game Genie hardware emulation (Game Genie ROM is now fully supported). +* added Action Replay hardware emulation (Action replay ROM is now fully supported). +* added S&K "Lock-On" hardware emulation (you can "lock" any games to Sonic & Knuckles). +* added Cartridge "hot swap" feature. +* added missing EEPROM support in some games. +* added accurate TMSS emulation (VDP lock-out) * fixed Realtec mapper emulation: fixes missing sound in Balloon Boy / Funny World. * fixed lightgun auto-detection: fixes default cursor position in Lethal Enforcers II. -* enabled simultaneous use of multitap & J-CART (Super Skidmarks 6-player mode) * lots of code cleanup, bugfixes & optimization. -[Gamecube/Wii] ---------------- -* implemented custom FONT engine (uses internal IPL font & GX hardware rendering). -* implemented custom GUI engine (uses GX hardware rendering & multithreading) -* implemented advanced menu interface (IR pointing, game snapshots, cheats & saves manager, visual & sound effects, BGM support, etc). -* improved audio/video synchronization to ensure 100% smooth video & audio playback. -* improved soft-reset button support, now works more like real Mega Drive / Genesis (model 1) reset button. -* improved lightgun cursors layout. -* added automatic ROM loading feature (last played game launches immediately when starting the emulator) -* added PAR codes and .pat files support -* fixed lot of stability issues and potential memory leaks. - -[Wii specific] ---------------- -* added Video Hardware "Gamma" control -* added Video Hardware "Trap Filter" control -* improved Mouse emulation through Wii remote -* compiled with devkitPPC r22 & libOGC 1.8.5 (includes SDHC & USB2 support through IOS58, removes DVDX support) - - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.3.1 (20/12/2008) (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Gamecube/Wii] - -* improved sound engine -* modified frame synchronization (now use audio DMA interrupt) - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX 1.3.0 (14/12/2008) (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [12/14/08] version 1.3.0 (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * YM2612 bugfixes (MAME core): .fixed EG Decay->Substain transition when SL & DR are minimals: fix tracks #3 and #9 in "Mega Turrican" @@ -216,36 +219,10 @@ Genesis Plus GX 1.3.0 (14/12/2008) (Eke-Eke) * added Blargg's NTSC Filters support (NTSC video artifacts emulation) * optimized VDP rendering core, rewrote 68k interface (memory handlers, cycle execution, interrupts): greatly improved emulation speed -[Gamecube/Wii] -* remove slowest libsamplerate settings under "HQ YM2612" option, only keeps SRC_LINEAR (faster) and SRC_SINC_FAST (better) -* added an option to enable/disable bilinear filtering -* rewrote video engine: improved horizontal scaling (VI+GX), improved rendering speed (direct texture mapping) -* removed embedded font, (re)enabled IPL font support: now should works for Qoob users too (thanks to emukiddid) -* fixed "Reset" button behavior, now acts more like Genesis Reset button ;-) -* patched libfat for faster SDCARD accesses (thanks to svpe) -* SRAM and SaveState filenames are now based on the ROM filename (for FAT devices only) -* various bugfixes, menu tweaks and code cleanup - -[Gamecube] - -* added 480p support in menu - -[Wii] - -* implemented fast scrolling in menu using Wiimote D-PAD -* added "Power" button support -* added USB Storage support -* Widescreen menu fix -* *new* libogc 1.7.0 features: SDHC support, Wiimote shutdown button support - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 080826 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [08/26/08] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * YM2612(MAME): fixed LFO phase update for CH3 special mode: fix sound effects in Warlock & Aladdin (thanks to AamirM) * YM2612(MAME): fixed EG attenuation level on "KEY ON": fix Ecco 2's splash sound @@ -261,21 +238,10 @@ Genesis Plus GX release 080826 (Eke-Eke) * added Konami Justifier emulation: fix lightgun support in Lethal Enforcers 1 & 2 * added Sega Mouse emulation (Populous 2, Body Count, Shangai 2, Fun'n Games, ...) -[Gamecube/Wii] -* added Wiimote support for Menacer/Justifier/Mouse -* added DVD support in Wii mode (no modchip required) -* added "Gun cursor" option to enable/disable gun position display -* added "Invert Mouse" option to invert Sega Mouse vertical axe (required by some games) -* improved Controller options: Wiimote/Nunchuk and Classical Controllers can now be affected separately to ANY player - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 080716 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [07/16/08] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * adjusted (again) HINT timings: fix Double Dragon 2 (game freezed), hopefully does not break anything else * fixed broken EEPROM support for Codemaster games @@ -290,107 +256,38 @@ Genesis Plus GX release 080716 (Eke-Eke) .fixed Channel 3 CSM mode emulation .implemented sample interpolation in MAME core to emulate the chip at original frequency (HQ YM2612 mode, from gens) -[Gamecube/Wii] -* added automatic alphabetical filesorting (Marty Disibio) -* added ROM History for faster ROM access (Marty Disibio) -* fixed a silly input bug in "ROM Infos" & "Game Genie" menus -* modified "Hard Reset" option -* improved display sharpness in original rendering mode (H40 cell mode only), filtering is now completely disabled -* enabled overscan emulation in "STRETCH" aspect mode also -* added support for horizontal wiimote handling in Menu (automatically used when the wiimote is not pointed towards the screen) -* improved Controller options - .prevented keys reconfiguration if device is not detected - .added support for up to 8 players (ISS Pro Deluxe, ...) - .each player can be affected to a custom device (GAMECUBE Pad, WIIMOTE/NUNCHUK or CLASSIC) - .added the ability to use classic controller & wiimote pad from the same port separately - .modified "soft-reset" key on the Wiimote to avoid "accidental" resets (now press Buttons + & * simultaneously) - .added MODE button mapping: use "START+Z" on gamepad or "Button Minus" on wiimote/classic (not reconfigurable) - .added automatic configuration save for controller options - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 080601 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [06/01/08] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * improved HCounter accuracy: fix graphic glitches in "Striker (Europe)" * improved HINT timing accuracy: fix flickering in "Zero The Kamikaze Squirrel (USA)" * improved rendering accuracy when backdrop color is modified during HBLANK (Road Rash I/II/III) * fixed broken Game Genie support + -[Gamecube/Wii] - -* added full horizontal scaling (up to 720 pixels) when using "stretch" aspect mode (use Xscale to increase width) -* added progressive mode support (480p) in menu also -* added automatic SRAM/FreezeState support (OFF by default, check "system options") -* added automatic configuration file support -* /genplus/saves is now automatically created if it does not exist -* use libfat automatic SDCARD detection: default slot is now always used when accessing SDCARD -* assigned Reset Button to Genesis Soft-Reset - -[Wii] - -* added automatic TV mode detection (from SYSCONF), no more PAL60 version needed -* added option to return to Wii System Menu -* fixed "TP reload" option: now compatible with HB channel -* removed SD-Gekko support (Wii slot becomes default slot) -* added Wii SD slot support for SRAM & FreezeState files -* added Wiimote, Nunchuk & Classic controllers support through libwiiuse (see User Manual for default keys) -* added customizable key mapping (for each configurations: wiimote only, wiimote+nunchuk or classic) - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 080419 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [04/19/08] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * modified VINT timings a little bit: fix lockup during Desert Strike's intro * corrected 68k interrupts handling: fix graphic glitches in Darius II/Sagaia -[Gamecube/Wii] -* fixed 60Hz "Bilinear" rendering mode (was broken in last release) -* fixed issue with the 1st file when browsing SDCARD through SD-Gekko -* fixed GX initialization: fix "freeze" issue that occured sometime when starting a game -* added "Wii Reboot" option -* added PAL 50hz support in menu (black borders) -* added progressive rendering mode support (480p) in Wii mode (not supported by the PAL60 version, use the other one !) -* compiled with a modified libogc: should definitely fix the PAL "red screen" issue for RGB-cable users (still use the PAL60 version !) - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 080406 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [04/06/08] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * updated SVP core: fix some perspective issues in Virtua Racing (thanks to Notaz) * added internal SAT update during VRAM Fill: fix unmasked sprites during Battletech's intro * fixed m68k core issues with gcc 4.2.3: fix Xperts, Lemmings 2, M1 Abrams Battle Tank * forced YM2612 Enveloppe update: fix intro music in Batman&Robin (thanks to Aamir) -[Gamecube/Wii] -* removed not working DVD features (Wii mode only) -* fixed Timers with PAL roms -* added EURGB60 TV mode support: fix "red screen" issue with PAL Wii when using RGB cable -* added PAL50 TV mode support (PAL and NTSC roms), see video options -* added "TP reload" option, use "System Reboot" (Wii mode only) -* added Front SD rom loading support with LFN & subdirectory browsing (Wii mode only) - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 080301 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [03/01/08] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * added SVP emulation: Virtua Racing is now emulated (big thanks to Notaz and TascoDeluxe) * fixed VDP registers behaviour when VDP Mode 4 is enabled: fix Bass Masters Classic Pro, Captain Planet & The Planeeters @@ -401,24 +298,10 @@ Genesis Plus GX release 080301 (Eke-Eke) * rewrote memory handlers for better modularity and some (little) speedup * reduced Savestate size -[Gamecube] -* compiled with last LibOGC (20080228): fix issues when unplugging controller, support for Wii mode (see release.txt) -* added "hard-coded" IPL font (no more direct access to BOOTROM): fix font problem for Qoob users -* added SDCARD Slot B support for loading Roms -* removed unused MAME PSG Core -* added 'Force DTACK' option for prototype games usually hanging on real hardware (example: Sonic Crackers) -* added an option to underclock SVP core (with default cycle count, Virtua Racing actually does not run fullspeed in GC mode) -* fixed frame timing in PAL mode -* fixed analog stick sensitivity - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 080107 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [01/07/08] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * fixed interleaved rom detection: roms with .smd extension should now work fine * fixed a recently introduced bug in VDP registers writes: fixes bad colors in Toy Story (intro) @@ -429,27 +312,10 @@ Genesis Plus GX release 080107 (Eke-Eke) * fixed unmapped ROM reads through Z80 Bank: fixes Zombie High (Proto) * added support for custom ROM/RAM mapping used by Game no Kanzume Otokuyou -[Gamecube] -* fixed broken SDCARD support for SRAM and Savestate files - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 071230 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Gamecube] - -* fixed ROM injector base address (DATA section 1) - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 071228 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [12/28/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * many sourcecode cleanup and optimization * completely rewrote EEPROM emulation: now support all known EEPROM types (24C01-24C65) and mappers (Sega, Acclaim, EA, Codemasters) @@ -480,25 +346,10 @@ used in a few games (now use internal game database) as external RAM. This shoul * improved Soft Reset emulation: X-Men 2 and Eternal Champions (random character selection) now work more like on real hardware. * added full overscan emulation (vertical & horizontal borders) for "pixel perfect" aspect ratio (tested against a real genesis) -[Gamecube] -* fixed rom checksum calculation (only used for rom information) -* some modifications in GX rendering code. -* added support for original Genesis/Megadrive NTSC & PAL video modes: this makes games looking exactly as on original hardware (progressive rendering with reduced resolution) -* added "Aspect" option to switch between ORIGINAL (aspect ratio is fixed and borders are emulated) and MANUAL SET (horizontal and vertical scaling can be manually configured, borders are not emulated) -* added "Overscan" option to disable the original borders color and always use black borders (only used when ORIGINAL Aspect mode is enabled) -* added support for up to 720 pixels horizontal resolution (needed for proper aspect ratio emulation) -* added "TV Mode" option to enable automatic switching to PAL(50Hz) TV mode when the Genesis runs in PAL mode -* added "Xshift" & "Yshift" settings to let you adjust display area position while keeping the original aspect ratio -* added option to disable/enable SSG-EG support in FM cores: this special mode is indeed not properly emulated and some games might sound wrong when enabled -* removed "CPU Type" option, you can also now force Region (JAP/EUR/USA) without reseting the game, choose USA or JAP for 60hz, EUR for 50hz, this can be useful to bypass game region protection at startup. - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070720 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [07/20/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * corrected TeamPlayer support: fix multiplayer in Gauntlet 4 (Sept. version), Pengo and a lot of others * added J-Cart support: enable multiplayer in Codemasters games (Pete Sampras, Micromachines games, Super Skidmarks) @@ -509,47 +360,18 @@ Genesis Plus GX release 070720 (Eke-Eke) * added "Soft Reset" combo (in game, use L+Z triggers): this should be like pressing the RESET button on a real Genesis and this is required in some games to enable special features or even complete the game (ex: X-Men). -[Gamecube] -* added separate configuration for PortA/PortB inputs (GAMEPAD, MULTITAP or NONE, see Joypad Config): this let you setting - PORTB as unplugged, which is needed in some games to access special modes or enable cheat codes (Alien Storm, X-Men...) -* Freezestate & SRAM files are now compressed (using zlib) -* FreezeState & SRAM files can now be saved/loaded to/from SDCARD: located in /genplus/saves/ from the root of your SDCARD -* changed initial ROMS directory for SDCARD user: now looking for /genplus/roms/ from the root of your SDCARD -* added user-transparent SRAM autoload (detection order is MCARD then SDCARD, SLOTA then SLOTB) -* "System reboot" is now used for console reboot and SD/PSO reload (if detected) -* added new font: now use original IPL font, extracted from Bootrom -* modified controls when going into the rom selection menu (DVD or SDCARD): - . use B button to go up one directory - . use Z button to quit the file selection menu - . use L/R triggers to go down/up one full page - . use Left/Right buttons or Analog stick to scroll the selected entry's filename when it can't be full displayed -* various menu rearrangment, minor bugfixes & sourcecode cleanup - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070621 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [06/21/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * added Multitap support (EA 4-Way Play and Sega Teamplayer): allowed up to four players in games supporting those peripherals -* added partial Sega Menacer lightgun support: automatically set when detecting the 6-in-1 Menacer game - -[Gamecube] - -* added 4.7GB DVD support for WII drives (the maximal allowed size for Gamecube DVD is still 1.35GB) -* removed MPAL video timings, always use 60Hz NTSC: fix display problems for PAL wii users (no more PAL50 version needed) -* added Console Reboot option in main menu (IPL Reboot) +* added partial Sega Menacer lightgun support (use Analog Stick): automatically set when detecting the 6-in-1 Menacer game - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070518 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [05/18/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * you can now switch between FM cores without reseting the game. FM registers value are automatically restored when switching. * removed the previous VINT timings modification because it brokes some games (Rocket Knight, Thunderforce III,...) @@ -561,18 +383,10 @@ For information, games that are actually detected and need special timings to ru .Sesame Street Counting Cafe (don't boot) .Chaos Engine/Soldiers of Fortune (graphic glitches on scrolling) -[Gamecube] -* modified PAL framesync a little bit: the 20ms period is now applied between the start of 2 consecutive frames, -no more between the end of the previous and the start of the next one, which seems more correct to me - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070508 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [05/08/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * VINT timings are now a little more accurate: fixes Sesame's Street Counting Cafe * SN76496 MAX_OUTPUT back to normal @@ -581,71 +395,29 @@ Genesis Plus GX release 070508 (Eke-Eke) * updated FM core to the latest MAME version * corrected DAC output level (fixes voices and some special FX being too low) * added support for Gens YM2612 (FM) core (MAME's one still remains default FM core) - -[Gamecube] - -* corrected L & R buttons assignment: fixes Genesis X & Z buttons being inverted * added configurable preamplification for each sound cores (see Emulator Options) * added some other configurable sound options (boost overall volume, FM improvment for Gens YM2612) ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070411 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [04/11/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- * corrected MAX_OUTPUT value in SN76496 core: fix PSG sound (SFX) volume -* removed unused sound buffer allocation +---------------------------------------------------------------------------------------------------------------------------------------------------- + [03/17/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070326 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Gamecube] - -* added DVD automount: automatically call libogc DVD_Mount function if ISO PVD reading failed (idea taken from softdev's last neocdredux release). This may be useful for loading roms from a DVD after booting from SDLOAD or after stopping DVD motor. -* added "DVD motor off" feature, like in others emulators -* corrected Memory Card mounting function: EXI_ProbeReset() function was never called if the first mounting attempt failed. Should fix some of the "Unable to mount memory card" errors. - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070322 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Gamecube] - - * added SDCARD subdirectory browsing and LFN (255 char. max) support - - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070317 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] - + * added an option to enable alternate line rendering timing (fix single line error in Road Rash series and Legend of Galahad's Intro) * Color RAM update now always reset color 0 to border color (fix color glitches in Mortal Kombat,...) (thanks to Noop's for the idea) -[Gamecube] - * remove some rendering unused code (only used by DOS version of genesis plus) for little speedup - * added an option to enable alternate line rendering timing (fix single line error in Road Rash series and Legend of Galahad's Intro) - * added last Softdev's modifications (normalised memory access and ASM GU functions used intead of 'C' ones) for some speedup - * updated gcaram.c to be compatible with last libogc version +---------------------------------------------------------------------------------------------------------------------------------------------------- + [03/09/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- - - ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070309 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] - -* little rendering code speedups * modified HV counter tables (fix graphic glitches in Skitchin's sky, Lotus 2 Recs, Panorama Cotton, Dashin Desperados & maybe more) * completely rewrote DMA timings emulation so that it works for all games (no more cpu freezing) * added all DMA tranfer rates handling for each three DMA modes and added dma busy flag emulation @@ -656,19 +428,13 @@ Genesis Plus GX release 070309 (Eke-Eke) * corrected IO Registers writes (fix Decap' Attack controls, no more need for alternate input) * corrected 6 Buttons Pad emulation (fix 6buttons detection in Mortal Kombat 3, Comix Zone and other 6-buttons compatible games) * modified sound mixing a bit according to Generator sourcecode (FM and PSG ratios seems more correct) -* added separate CPU Region (USA, Europe, Japan,...) & Speed (PAL or NTSC) choice in menu options -* modified main frame synchro in PAL mode (fix sound glitch in this mode), thanks to Softdev for the solution -* added savestates support (go to SRAM menu, memory card supports only) +---------------------------------------------------------------------------------------------------------------------------------------------------- + [02/07/07] (Eke-Eke) +---------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX release 070207 (Eke-Eke) ---------------------------------------------------------------------------------------------------------- - -[Core] - -* fm timers fixed (fix missing music in Castle of Illusion, Quackshot, Undead Line, Wonderboy in Monster Lair, Cal 50, Turbo Outrun, Thundeforce 4 and maybe more) +* fixed fm timers (fix missing music in Castle of Illusion, Quackshot, Undead Line, Wonderboy in Monster Lair, Cal 50, Turbo Outrun, Thundeforce 4 and maybe more) * added complete EEPROM emulation (save support now works fine in Wonderboy5, Megaman Willy Wars, NBA Jam...) (credits to Notaz, adapted from Picodrive code) * added preliminar dma timing emulation (fix bottom screen in Legend of Galahad) (credits to Notaz, adapted from Picodrive code) * hack: clear Vint pending after Hint (INT level 4) acknowledge (fix Fatal Rewind) @@ -679,47 +445,48 @@ Genesis Plus GX release 070207 (Eke-Eke) * modified dma fill operation for big endian platform (fix Contra Hardcorps gfx garbage) +---------------------------------------------------------------------------------------------------------------------------------------------------- + [05/25/03] (Charles MacDonald) +---------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX WIP 1.2 (Softdev) ---------------------------------------------------------------------------------------------------------- - -[Gamecube] - -* Added partial zip support (unzip.c) + * Fixed a typo that made Z80 banked access to the VDP registers always fail. +---------------------------------------------------------------------------------------------------------------------------------------------------- + [05/17/03] (Charles MacDonald) +---------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX WIP 1.1 (Softdev) ---------------------------------------------------------------------------------------------------------- - -[Core] - -* sio.c added -* Added six button pad support from x86 Gens -* Additional changes based on Charles MacDonald's gen-hw.txt + * Modified the rendering code to handle unaligned longword access to memory. +---------------------------------------------------------------------------------------------------------------------------------------------------- + [04/20/03] (Charles MacDonald) +---------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX WIP 1 - 7 March 2006 (Softdev) ---------------------------------------------------------------------------------------------------------- - -[Core] - -* Updated SN76496 driver - -[Gamecube] - -* Added GX Hardware Scaling + * Modified 68000 emulator to prevent 'tas.b $mem' from writing data back + after a read (fixes Gargoyles). + * Fixed bug in 68000 emulator to swap order of words written for address + register indirect pre-decremented writes (fixes Jim Power graphics). + * Added support for 240-line displays (for Super Skidmarks). + * Rewrote part of the interrupt handling (fixes some raster effects). + * Removed sprite collision detection code (never really worked). + * Optimized sprite rendering inner loop. +---------------------------------------------------------------------------------------------------------------------------------------------------- + [04/13/03] (Charles MacDonald) +---------------------------------------------------------------------------------------------------------------------------------------------------- + * Finished up memory map for VDP DMA V-bus reads. + * Fixed handling of 68000 writes to I/O chip at even addresses. + * Fixed bit 7 handling of control register in I/O chip. + * Finished up Z80 memory map. + * Added code to handle Genesis hardware lock-ups. + * Removed some faulty code from the 68000 memory map handlers. ---------------------------------------------------------------------------------------------------------- -Genesis Plus GX WIP 0 (Softdev) ---------------------------------------------------------------------------------------------------------- -[Gamecube] +---------------------------------------------------------------------------------------------------------------------------------------------------- + [03/22/03] (Charles MacDonald) +---------------------------------------------------------------------------------------------------------------------------------------------------- + + * Completed implementation of Z80 banked memory handlers. -* initial port based on Genesis Plus 1.2a from Charles McDonald (http://cgfm2.emuviews.com/) diff --git a/source/win/LICENSE.txt b/source/win/LICENSE.txt new file mode 100644 index 0000000..f28a399 --- /dev/null +++ b/source/win/LICENSE.txt @@ -0,0 +1,552 @@ + +Unless otherwise explicitly stated, all code in Genesis Plus is released +under the following license: + +Copyright Charles MacDonald +Some portions copyright Nicola Salmoria and the MAME team +All rights reserved. + +Copyright (c) 2006-2011 Eke-Eke +All rights reserved. + +Redistribution and use of this code or any derivative works are permitted +provided that the following conditions are met: + +* Redistributions may not be sold, nor may they be used in a commercial +product or activity. + +* Redistributions that are modified from the original source must include the +complete source code, including the source code for all components used by a +binary built from the modified sources. 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. + +* Redistributions must reproduce the above copyright notice, this list of +conditions and the following disclaimer in the documentation and/or other +materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------------------------- + + +NTSC Filter, Blip Buffer and FIR Resampling libraries are distributed under the +terms of the GNU Lesser General Public License + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +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 and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, 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 library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete 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 distribute a copy of this License along with the +Library. + + 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 Library or any portion +of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +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 Library, 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 Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you 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. + + If distribution of 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 satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library 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. + + 9. 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 Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +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 with +this License. + + 11. 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 Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library 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 Library. + +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. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser 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 Library +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 Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +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 + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "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 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. 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 LIBRARY 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 +LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. 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 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.1 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; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/source/win/README.txt b/source/win/README.txt new file mode 100644 index 0000000..33f0975 --- /dev/null +++ b/source/win/README.txt @@ -0,0 +1,130 @@ + ---------------------------------------------------------------------------- + Genesis Plus + ---------------------------------------------------------------------------- + + based on the original version 1.3 + by Charles Mac Donald + WWW: http://cgfm2.emuviews.com + + version 1.6 + backported from Genesis Plus GX + by Eke-Eke + WWW: http://code.google.com/p/genplus-gx + + + What's New + ---------- + + see CHANGELOG.txt + + + Features + --------- + + * accurate SG-1000, Mark-III, Master System (I & II), Game Gear, Genesis & Mega Drive emulation (incl. backwards compatibility modes) + * NTSC (60Hz) & PAL (50Hz) hardware emulation + * highly accurate 68000 & Z80 CPU emulation + * highly accurate VDP emulation (all rendering modes, HBLANK, DMA, FIFO, HV interrupts, undocumented registers, display mid-line changes…) + * cycle-accurate YM2612 emulation (FM synthesis is done at the original frequency, using FIR resampling) + * cycle-accurate chip synchronization (68000/Z80/YM2612/SN76489) + * basic hardware latency emulation (VDP/68k, Z80/68k) + * full overscan area (horizontal & vertical colored borders) emulation (optional) + * accurate TMSS model emulation incl. internal BIOS support (optional) + * Blargg's software NTSC filters support (optional) + * PICO emulation (partial) + * 2-buttons, 3-buttons & 6-buttons controllers emulation + * Sega Team Player & EA 4-Way Play multitap adapters emulation + * Sega Light Phaser, Menacer & Konami Justifier lightguns emulation + * Sega Mouse emulation + * Sega Activator emulation + * XE-1AP emulation + * Sega Paddle & Sports Pad emulation + * Terebe Oekaki emulation + * J-Cart adapter support(Micro Machines & Pete Sampras series, Super Skidmarks) + * SVP DSP emulation (Virtua Racing) + * SRAM support (up to 64kB) + * I2C (24Cxx) and MicroWire (93C46) EEPROM emulation (all known chips) + * ROM bankswitch hardware emulation (Super Street Fighter 2) + * SRAM bankswitch hardware emulation (Phantasy Star 4, Legend of Thor, Sonic the Hedgehog 3) + * emulation of banking & copy protection devices used in all known unlicensed/pirate cartridges + * emulation of all known Master System & Game Gear cartridge mappers + * native Game Genie & Action Replay hardware emulation + * Lock-On hardware emulation + * support for ROM image up to 10MB (Ultimate MK3 hack) + + + Usage + ----- + + The Windows version runs windowed in a 16-bit desktop with 48Hz sound using SDL but + without joystick support. + + + Controls + ----- + + Arrow Keys - Directional pad + A/Q,S,D,F - buttons A, B(1), C(2), START + W,X,C,V - buttons X, Y, Z, MODE if 6-buttons controller is enabled + Tab - Hard Reset + Esc - Exit program + + F2 - Toggle Fullscreen/Windowed mode + F4 - Toggle Audio (Turbo mode must be disabled first) + F6 - Toggle Turbo mode (Audio must be disabled first) + F7 - Load Savestate (game.gpz) + F8 - Save Savestate (game.gpz) + F9 - Toggle VDP mode: PAL(50hz)/NTSC(60hz) + F10 - Soft Reset + F11 - Toggle Border emulation + F12 - Toggle Player # (test only) + + + The mouse is used for lightguns, Sega Mouse, PICO & Terebi Oekaki tablet (automatically detected when loading supported game). + + A SRAM file (game.srm) is automatically saved on exit and loaded on startup. + + + Credits and Acknowlegements + --------------------------- + + Original code by Charles MacDonald + + Modified Genesis Plus GX code by Eke-Eke (http://code.google.com/p/genplus-gx ) + + The Genesis emulator authors: Bart Trzynadlowski, Steve Snake, Stef, Notaz, AamirM + + The regular people at spritesmind.net and smspower.org. + + The MAME team for the CPU and sound chip emulators. + + Maxim for his SN76489 emulator. + + Nemesis for his researches about the YM2612 and VDP. + + Notaz for his SVP emulator. + + Tasco Deluxe for his documentation of Realtec mapper. + + Haze for his reverse-engineering of most unlicensed games protection. + + Shay Green (Blargg) for his FIR Resampler & NTSC Video Filter. + + Neil C for his 3-Band EQ implementation. + + Jean-Loup Gailly and Mark Adler for their useful zip library. + + + Contact + ------- + + Eke-Eke + E-mail: ekeeke31@gmail.com + WWW: http://code.google.com/p/genplus-gx + + + Legal + ----- + + See license.txt for licensing terms. + diff --git a/source/win/config.c b/source/win/config.c new file mode 100644 index 0000000..23fcfc9 --- /dev/null +++ b/source/win/config.c @@ -0,0 +1,50 @@ + +#include "osd.h" + +t_config config; + + +void set_config_defaults(void) +{ + int i; + + /* sound options */ + config.psg_preamp = 150; + config.fm_preamp = 100; + config.hq_fm = 1; + config.psgBoostNoise = 0; + config.filter = 1; + config.low_freq = 200; + config.high_freq = 8000; + config.lg = 1.0; + config.mg = 1.0; + config.hg = 1.0; + config.lp_range = 60; + config.rolloff = 0.995; + config.dac_bits = 14; + config.ym2413 = 2; /* = AUTO (0 = always OFF, 1 = always ON) */ + + /* system options */ + config.system = 0; /* = AUTO (or SYSTEM_SG, SYSTEM_MARKIII, SYSTEM_SMS, SYSTEM_SMS2, SYSTEM_GG, SYSTEM_MD) */ + config.region_detect = 0; /* = AUTO (1 = USA, 2 = EUROPE, 3 = JAPAN/NTSC, 4 = JAPAN/PAL) */ + config.force_dtack = 0; + config.addr_error = 1; + config.tmss = 0; + config.lock_on = 0; /* = OFF (can be TYPE_SK, TYPE_GG & TYPE_AR) */ + config.romtype = 0; /* ROM mirroring type (see md_cart_hw.c) */ + + /* display options */ + config.overscan = 3; /* = both ON (0 = no borders , 1 = vertical borders only, 2 = horizontal borders only) */ + config.render = 0; /* 1 = double resolution output (only when interlaced mode 2 is enabled) */ + + /* controllers options */ + input.system[0] = SYSTEM_MD_GAMEPAD; + input.system[1] = SYSTEM_MD_GAMEPAD; + config.gun_cursor[0] = 1; + config.gun_cursor[1] = 1; + config.invert_mouse = 0; + for (i=0;i +#include + +int load_archive(char *filename) +{ + int size = 0; + char msg[64]; + + /* ROM buffer should be allocated first */ + if (cart.rom == NULL) + { + return 0; + } + + if(check_zip(filename)) + { + unz_file_info info; + int ret = 0; + + /* Attempt to open the archive */ + unzFile *fd = unzOpen(filename); + if (!fd) return 0; + + /* Go to first file in archive */ + ret = unzGoToFirstFile(fd); + if(ret != UNZ_OK) + { + unzClose(fd); + return 0; + } + + /* Get file informations and update filename */ + ret = unzGetCurrentFileInfo(fd, &info, filename, 128, NULL, 0, NULL, 0); + if(ret != UNZ_OK) + { + unzClose(fd); + return 0; + } + + /* Open the file for reading */ + ret = unzOpenCurrentFile(fd); + if(ret != UNZ_OK) + { + unzClose(fd); + return 0; + } + + /* Retrieve uncompressed file size */ + size = info.uncompressed_size; + if(size > MAXROMSIZE) + { + unzClose(fd); + return 0; + } + + /* Read (decompress) the file */ + ret = unzReadCurrentFile(fd, cart.rom, info.uncompressed_size); + if(ret != info.uncompressed_size) + { + unzCloseCurrentFile(fd); + unzClose(fd); + return 0; + } + + /* Close the current file */ + ret = unzCloseCurrentFile(fd); + if(ret != UNZ_OK) + { + unzClose(fd); + return 0; + } + + /* Close the archive */ + ret = unzClose(fd); + if(ret != UNZ_OK) return 0; + } + else + { + /* Open file */ + gzFile *gd = gzopen(filename, "rb"); + if (!gd) return 0; + + /* Get file size */ + size = gzsize(gd); + + /* Check file size */ + if(size > MAXROMSIZE) + { + gzclose(gd); + return 0; + } + + /* Read file data */ + gzread(gd, cart.rom, size); + + /* Close file */ + gzclose(gd); + } + + /* Return loaded ROM size */ + return size; +} + +/* + Verifies if a file is a ZIP archive or not. + Returns: 1= ZIP archive, 0= not a ZIP archive +*/ +int check_zip(char *filename) +{ + uint8 buf[2]; + FILE *fd = fopen(filename, "rb"); + if(!fd) return (0); + fread(buf, 2, 1, fd); + fclose(fd); + if(memcmp(buf, "PK", 2) == 0) return (1); + return (0); +} + + +/* + Returns the size of a GZ compressed file. +*/ +int gzsize(gzFile *gd) +{ + #define CHUNKSIZE (0x10000) + int size = 0, length = 0; + unsigned char buffer[CHUNKSIZE]; + gzrewind(gd); + do + { + size = gzread(gd, buffer, CHUNKSIZE); + if(size <= 0) break; + length += size; + } + while (!gzeof(gd)); + gzrewind(gd); + return (length); + #undef CHUNKSIZE +} diff --git a/source/win/fileio.h b/source/win/fileio.h new file mode 100644 index 0000000..ef7d7c3 --- /dev/null +++ b/source/win/fileio.h @@ -0,0 +1,50 @@ +/* + * fileio.c + * + * Load a normal file, or ZIP/GZ archive. + * Returns loaded ROM size (zero if an error occured) + * + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald + * modified by Eke-Eke (Genesis Plus GX) + * + * Redistribution and use of this code or any derivative works are permitted + * provided that the following conditions are met: + * + * - Redistributions may not be sold, nor may they be used in a commercial + * product or activity. + * + * - Redistributions that are modified from the original source must include the + * complete source code, including the source code for all components used by a + * binary built from the modified sources. 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. + * + * - Redistributions must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************************/ + +#ifndef _FILEIO_H_ +#define _FILEIO_H_ + +/* Function prototypes */ +int load_archive(char *filename); +int check_zip(char *filename); +int gzsize(gzFile *gd); + +#endif /* _FILEIO_H_ */ diff --git a/source/win/icon.rc b/source/win/icon.rc new file mode 100644 index 0000000..0b47594 --- /dev/null +++ b/source/win/icon.rc @@ -0,0 +1 @@ +MAINICON ICON "md.ico" diff --git a/source/win/main.c b/source/win/main.c new file mode 100644 index 0000000..9329068 --- /dev/null +++ b/source/win/main.c @@ -0,0 +1,780 @@ +#include + +#include "SDL.h" +#include "SDL_thread.h" + +#include "shared.h" +#include "sms_ntsc.h" +#include "md_ntsc.h" + +#define SOUND_FREQUENCY 48000 +#define SOUND_SAMPLES_SIZE 2048 + +#define VIDEO_WIDTH 320 +#define VIDEO_HEIGHT 240 + +int joynum = 0; + +int log_error = 0; +int debug_on = 0; +int turbo_mode = 0; +int use_sound = 1; +int fullscreen = 0; /* SDL_FULLSCREEN */ + +/* sound */ + +struct { + char* current_pos; + char* buffer; + int current_emulated_samples; +} sdl_sound; + +static void sdl_sound_callback(void *userdata, Uint8 *stream, int len) +{ + if(sdl_sound.current_emulated_samples < len) { + memset(stream, 0, len); + } + else { + memcpy(stream, sdl_sound.buffer, len); + /* loop to compensate desync */ + do { + sdl_sound.current_emulated_samples -= len; + } while(sdl_sound.current_emulated_samples > 2 * len); + memcpy(sdl_sound.buffer, + sdl_sound.current_pos - sdl_sound.current_emulated_samples, + sdl_sound.current_emulated_samples); + sdl_sound.current_pos = sdl_sound.buffer + sdl_sound.current_emulated_samples; + } +} + +static int sdl_sound_init() +{ + int n; + SDL_AudioSpec as_desired, as_obtained; + + if(SDL_Init(SDL_INIT_AUDIO) < 0) { + MessageBox(NULL, "SDL Audio initialization failed", "Error", 0); + return 0; + } + + as_desired.freq = SOUND_FREQUENCY; + as_desired.format = AUDIO_S16LSB; + as_desired.channels = 2; + as_desired.samples = SOUND_SAMPLES_SIZE; + as_desired.callback = sdl_sound_callback; + + if(SDL_OpenAudio(&as_desired, &as_obtained) == -1) { + MessageBox(NULL, "SDL Audio open failed", "Error", 0); + return 0; + } + + if(as_desired.samples != as_obtained.samples) { + MessageBox(NULL, "SDL Audio wrong setup", "Error", 0); + return 0; + } + + sdl_sound.current_emulated_samples = 0; + n = SOUND_SAMPLES_SIZE * 2 * sizeof(short) * 11; + sdl_sound.buffer = (char*)malloc(n); + if(!sdl_sound.buffer) { + MessageBox(NULL, "Can't allocate audio buffer", "Error", 0); + return 0; + } + memset(sdl_sound.buffer, 0, n); + sdl_sound.current_pos = sdl_sound.buffer; + return 1; +} + +static void sdl_sound_update() +{ + int i; + short* p; + + int size = audio_update(); + + if (use_sound) + { + SDL_LockAudio(); + p = (short*)sdl_sound.current_pos; + for(i = 0; i < size; ++i) { + *p = snd.buffer[0][i]; + ++p; + *p = snd.buffer[1][i]; + ++p; + } + sdl_sound.current_pos = (char*)p; + sdl_sound.current_emulated_samples += size * 2 * sizeof(short); + SDL_UnlockAudio(); + } +} + +static void sdl_sound_close() +{ + SDL_PauseAudio(1); + SDL_CloseAudio(); + if (sdl_sound.buffer) + free(sdl_sound.buffer); +} + +/* video */ +md_ntsc_t *md_ntsc; +sms_ntsc_t *sms_ntsc; + +struct { + SDL_Surface* surf_screen; + SDL_Surface* surf_bitmap; + SDL_Rect srect; + SDL_Rect drect; + Uint32 frames_rendered; +} sdl_video; + +static int sdl_video_init() +{ + if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { + MessageBox(NULL, "SDL Video initialization failed", "Error", 0); + return 0; + } + sdl_video.surf_screen = SDL_SetVideoMode(VIDEO_WIDTH, VIDEO_HEIGHT, 16, SDL_SWSURFACE | fullscreen); + sdl_video.surf_bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, 720, 576, 16, 0, 0, 0, 0); + sdl_video.frames_rendered = 0; + SDL_ShowCursor(0); + + return 1; +} + +static void sdl_video_update() +{ + system_frame(0); + + /* viewport size changed */ + if(bitmap.viewport.changed & 1) + { + bitmap.viewport.changed &= ~1; + + /* source bitmap */ + sdl_video.srect.w = bitmap.viewport.w+2*bitmap.viewport.x; + sdl_video.srect.h = bitmap.viewport.h+2*bitmap.viewport.y; + sdl_video.srect.x = 0; + sdl_video.srect.y = 0; + if (sdl_video.srect.w > VIDEO_WIDTH) + { + sdl_video.srect.x = (sdl_video.srect.w - VIDEO_WIDTH) / 2; + sdl_video.srect.w = VIDEO_WIDTH; + } + if (sdl_video.srect.h > VIDEO_HEIGHT) + { + sdl_video.srect.y = (sdl_video.srect.h - VIDEO_HEIGHT) / 2; + sdl_video.srect.h = VIDEO_HEIGHT; + } + + /* destination bitmap */ + sdl_video.drect.w = sdl_video.srect.w; + sdl_video.drect.h = sdl_video.srect.h; + sdl_video.drect.x = (VIDEO_WIDTH - sdl_video.drect.w) / 2; + sdl_video.drect.y = (VIDEO_HEIGHT - sdl_video.drect.h) / 2; + + /* clear destination surface */ + SDL_FillRect(sdl_video.surf_screen, 0, 0); + + /*if (config.render && (interlaced || config.ntsc)) rect.h *= 2; + if (config.ntsc) rect.w = (reg[12]&1) ? MD_NTSC_OUT_WIDTH(rect.w) : SMS_NTSC_OUT_WIDTH(rect.w); + if (config.ntsc) + { + sms_ntsc = (sms_ntsc_t *)malloc(sizeof(sms_ntsc_t)); + md_ntsc = (md_ntsc_t *)malloc(sizeof(md_ntsc_t)); + + switch (config.ntsc) + { + case 1: + sms_ntsc_init(sms_ntsc, &sms_ntsc_composite); + md_ntsc_init(md_ntsc, &md_ntsc_composite); + break; + case 2: + sms_ntsc_init(sms_ntsc, &sms_ntsc_svideo); + md_ntsc_init(md_ntsc, &md_ntsc_svideo); + break; + case 3: + sms_ntsc_init(sms_ntsc, &sms_ntsc_rgb); + md_ntsc_init(md_ntsc, &md_ntsc_rgb); + break; + } + } + else + { + if (sms_ntsc) + { + free(sms_ntsc); + sms_ntsc = NULL; + } + + if (md_ntsc) + { + free(md_ntsc); + md_ntsc = NULL; + } + } */ + } + + SDL_BlitSurface(sdl_video.surf_bitmap, &sdl_video.srect, sdl_video.surf_screen, &sdl_video.drect); + SDL_UpdateRect(sdl_video.surf_screen, 0, 0, 0, 0); + + ++sdl_video.frames_rendered; +} + +static void sdl_video_close() +{ + if (sdl_video.surf_bitmap) + SDL_FreeSurface(sdl_video.surf_bitmap); + if (sdl_video.surf_screen) + SDL_FreeSurface(sdl_video.surf_screen); +} + +/* Timer Sync */ + +struct { + SDL_sem* sem_sync; + unsigned ticks; +} sdl_sync; + +/* sync */ + +static Uint32 sdl_sync_timer_callback(Uint32 interval) +{ + SDL_SemPost(sdl_sync.sem_sync); + char caption[100]; + sdl_sync.ticks++; + if (sdl_sync.ticks == (vdp_pal ? 50 : 20)) + { + int fps = vdp_pal ? (sdl_video.frames_rendered / 3) : sdl_video.frames_rendered; + sdl_sync.ticks = sdl_video.frames_rendered = 0; + sprintf(caption,"%d fps - %s", fps, rominfo.international); + SDL_WM_SetCaption(caption, NULL); + } + return interval; +} + +static int sdl_sync_init() +{ + if(SDL_InitSubSystem(SDL_INIT_TIMER|SDL_INIT_EVENTTHREAD) < 0) + { + MessageBox(NULL, "SDL Timer initialization failed", "Error", 0); + return 0; + } + + sdl_sync.sem_sync = SDL_CreateSemaphore(0); + sdl_sync.ticks = 0; + return 1; +} + +static void sdl_sync_close() +{ + if(sdl_sync.sem_sync) + SDL_DestroySemaphore(sdl_sync.sem_sync); +} + +static const uint16 vc_table[4][2] = +{ + /* NTSC, PAL */ + {0xDA , 0xF2}, /* Mode 4 (192 lines) */ + {0xEA , 0x102}, /* Mode 5 (224 lines) */ + {0xDA , 0xF2}, /* Mode 4 (192 lines) */ + {0x106, 0x10A} /* Mode 5 (240 lines) */ +}; + +static int sdl_control_update(SDLKey keystate) +{ + switch (keystate) + { + case SDLK_TAB: + { + system_init(); + system_reset(); + break; + } + + case SDLK_F2: + { + if (fullscreen) fullscreen = 0; + else fullscreen = SDL_FULLSCREEN; + sdl_video.surf_screen = SDL_SetVideoMode(VIDEO_WIDTH, VIDEO_HEIGHT, 16, SDL_SWSURFACE | fullscreen); + break; + } + + case SDLK_F3: + { + config.render ^=1; + break; + } + + case SDLK_F4: + { + if (!turbo_mode) use_sound ^= 1; + break; + } + + case SDLK_F5: + { + log_error ^= 1; + break; + } + + case SDLK_F6: + { + if (!use_sound) turbo_mode ^=1; + break; + } + + case SDLK_F7: + { + FILE *f = fopen("game.gpz","r+b"); + if (f) + { + uint8 buf[STATE_SIZE]; + fread(&buf, STATE_SIZE, 1, f); + state_load(buf); + fclose(f); + } + break; + } + + case SDLK_F8: + { + FILE *f = fopen("game.gpz","w+b"); + if (f) + { + uint8 buf[STATE_SIZE]; + state_save(buf); + fwrite(&buf, STATE_SIZE, 1, f); + fclose(f); + } + break; + } + + case SDLK_F9: + { + vdp_pal ^= 1; + + /* reset region code */ + region_code &= ~0x40; + region_code |= (vdp_pal << 6); + if (system_hw == SYSTEM_MD) + { + io_reg[0x00] = 0x20 | region_code | (config.tmss & 1); + } + else + { + io_reg[0x00] = 0x80 | (region_code >> 1); + } + + /* reinitialize audio timings */ + audio_init(snd.sample_rate, snd.frame_rate); + + /* reinitialize sound emulation */ + sound_restore(); + + /* reintialize VDP */ + vdp_init(); + + /* reintialize VDP Status flag */ + if (system_hw & SYSTEM_MD) + { + status = (status & ~1) | vdp_pal; + } + + /* reinitialize VC max value */ + switch (bitmap.viewport.h) + { + case 192: + vc_max = vc_table[0][vdp_pal]; + break; + case 224: + vc_max = vc_table[1][vdp_pal]; + break; + case 240: + vc_max = vc_table[3][vdp_pal]; + break; + } + + /* reinitialize display area */ + bitmap.viewport.changed = 3; + break; + } + + case SDLK_F10: + { + gen_reset(0); + break; + } + + case SDLK_F11: + { + config.overscan = (config.overscan + 1) & 3; + if (system_hw == SYSTEM_GG) + { + bitmap.viewport.x = (config.overscan & 2) ? 14 : -48; + } + else + { + bitmap.viewport.x = (config.overscan & 2) * 7; + } + bitmap.viewport.changed = 3; + break; + } + + case SDLK_F12: + { + joynum = (joynum + 1) % MAX_DEVICES; + while (input.dev[joynum] == NO_DEVICE) + { + joynum = (joynum + 1) % MAX_DEVICES; + } + break; + } + + case SDLK_ESCAPE: + { + return 0; + } + + default: + break; + } + + return 1; +} + +int sdl_input_update(void) +{ + uint8 *keystate = SDL_GetKeyState(NULL); + + /* reset input */ + input.pad[joynum] = 0; + + switch (input.dev[joynum]) + { + case DEVICE_LIGHTGUN: + { + /* get mouse (absolute values) */ + int x,y; + int state = SDL_GetMouseState(&x,&y); + + /* Calculate X Y axis values */ + input.analog[joynum][0] = (x * bitmap.viewport.w) / VIDEO_WIDTH; + input.analog[joynum][1] = (y * bitmap.viewport.h) / VIDEO_HEIGHT; + + /* TRIGGER, B, C (Menacer only), START (Menacer & Justifier only) */ + if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_A; + if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_B; + if(state & SDL_BUTTON_MMASK) input.pad[joynum] |= INPUT_C; + if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; + break; + } + + case DEVICE_PADDLE: + { + /* get mouse (absolute values) */ + int x; + int state = SDL_GetMouseState(&x, NULL); + + /* Range is [0;256], 128 being middle position */ + input.analog[joynum][0] = x * 256 /VIDEO_WIDTH; + + /* Button I -> 0 0 0 0 0 0 0 I*/ + if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; + + break; + } + + case DEVICE_SPORTSPAD: + { + /* get mouse (relative values) */ + int x,y; + int state = SDL_GetRelativeMouseState(&x,&y); + + /* Range is [0;256] */ + input.analog[joynum][0] = (unsigned char)(-x & 0xFF); + input.analog[joynum][1] = (unsigned char)(-y & 0xFF); + + /* Buttons I & II -> 0 0 0 0 0 0 II I*/ + if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; + if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_C; + + break; + } + + case DEVICE_MOUSE: + { + /* get mouse (relative values) */ + int x,y; + int state = SDL_GetRelativeMouseState(&x,&y); + + /* Sega Mouse range is [-256;+256] */ + input.analog[joynum][0] = x * 2; + input.analog[joynum][1] = y * 2; + + /* Vertical movement is upsidedown */ + if (!config.invert_mouse) + input.analog[joynum][1] = 0 - input.analog[joynum][1]; + + /* Start,Left,Right,Middle buttons -> 0 0 0 0 START MIDDLE RIGHT LEFT */ + if(state & SDL_BUTTON_LMASK) input.pad[joynum] |= INPUT_B; + if(state & SDL_BUTTON_RMASK) input.pad[joynum] |= INPUT_C; + if(state & SDL_BUTTON_MMASK) input.pad[joynum] |= INPUT_A; + if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; + + break; + } + + case DEVICE_XE_A1P: + { + /* A,B,C,D,Select,START,E1,E2 buttons -> E1(?) E2(?) START SELECT(?) A B C D */ + if(keystate[SDLK_a]) input.pad[joynum] |= INPUT_START; + if(keystate[SDLK_s]) input.pad[joynum] |= INPUT_A; + if(keystate[SDLK_d]) input.pad[joynum] |= INPUT_C; + if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_Y; + if(keystate[SDLK_z]) input.pad[joynum] |= INPUT_B; + if(keystate[SDLK_x]) input.pad[joynum] |= INPUT_X; + if(keystate[SDLK_c]) input.pad[joynum] |= INPUT_MODE; + if(keystate[SDLK_v]) input.pad[joynum] |= INPUT_Z; + + /* Left Analog Stick (bidirectional) */ + if(keystate[SDLK_UP]) input.analog[joynum][1]-=2; + else if(keystate[SDLK_DOWN]) input.analog[joynum][1]+=2; + else input.analog[joynum][1] = 128; + if(keystate[SDLK_LEFT]) input.analog[joynum][0]-=2; + else if(keystate[SDLK_RIGHT]) input.analog[joynum][0]+=2; + else input.analog[joynum][0] = 128; + + /* Right Analog Stick (unidirectional) */ + if(keystate[SDLK_KP8]) input.analog[joynum+1][0]-=2; + else if(keystate[SDLK_KP2]) input.analog[joynum+1][0]+=2; + else if(keystate[SDLK_KP4]) input.analog[joynum+1][0]-=2; + else if(keystate[SDLK_KP6]) input.analog[joynum+1][0]+=2; + else input.analog[joynum+1][0] = 128; + + /* Limiters */ + if (input.analog[joynum][0] > 0xFF) input.analog[joynum][0] = 0xFF; + else if (input.analog[joynum][0] < 0) input.analog[joynum][0] = 0; + if (input.analog[joynum][1] > 0xFF) input.analog[joynum][1] = 0xFF; + else if (input.analog[joynum][1] < 0) input.analog[joynum][1] = 0; + if (input.analog[joynum+1][0] > 0xFF) input.analog[joynum+1][0] = 0xFF; + else if (input.analog[joynum+1][0] < 0) input.analog[joynum+1][0] = 0; + if (input.analog[joynum+1][1] > 0xFF) input.analog[joynum+1][1] = 0xFF; + else if (input.analog[joynum+1][1] < 0) input.analog[joynum+1][1] = 0; + + break; + } + + case DEVICE_PICO: + { + /* get mouse (absolute values) */ + int x,y; + int state = SDL_GetMouseState(&x,&y); + + /* Calculate X Y axis values */ + input.analog[0][0] = 0x3c + (x * (0x17c-0x03c+1)) / VIDEO_WIDTH; + input.analog[0][1] = 0x1fc + (y * (0x2f7-0x1fc+1)) / VIDEO_HEIGHT; + + /* Map mouse buttons to player #1 inputs */ + if(state & SDL_BUTTON_MMASK) pico_current++; + if(state & SDL_BUTTON_RMASK) input.pad[0] |= INPUT_B; + if(state & SDL_BUTTON_LMASK) input.pad[0] |= INPUT_A; + + break; + } + + case DEVICE_TEREBI: + { + /* get mouse (absolute values) */ + int x,y; + int state = SDL_GetMouseState(&x,&y); + + /* Calculate X Y axis values */ + input.analog[0][0] = (x * 250) / VIDEO_WIDTH; + input.analog[0][1] = (y * 250) / VIDEO_HEIGHT; + + /* Map mouse buttons to player #1 inputs */ + if(state & SDL_BUTTON_RMASK) input.pad[0] |= INPUT_B; + + break; + } + + case DEVICE_ACTIVATOR: + { + if(keystate[SDLK_g]) input.pad[joynum] |= INPUT_ACTIVATOR_7L; + if(keystate[SDLK_h]) input.pad[joynum] |= INPUT_ACTIVATOR_7U; + if(keystate[SDLK_j]) input.pad[joynum] |= INPUT_ACTIVATOR_8L; + if(keystate[SDLK_k]) input.pad[joynum] |= INPUT_ACTIVATOR_8U; + } + + default: + { + if(keystate[SDLK_a]) input.pad[joynum] |= INPUT_A; + if(keystate[SDLK_s]) input.pad[joynum] |= INPUT_B; + if(keystate[SDLK_d]) input.pad[joynum] |= INPUT_C; + if(keystate[SDLK_f]) input.pad[joynum] |= INPUT_START; + if(keystate[SDLK_z]) input.pad[joynum] |= INPUT_X; + if(keystate[SDLK_x]) input.pad[joynum] |= INPUT_Y; + if(keystate[SDLK_c]) input.pad[joynum] |= INPUT_Z; + if(keystate[SDLK_v]) input.pad[joynum] |= INPUT_MODE; + + if(keystate[SDLK_UP]) input.pad[joynum] |= INPUT_UP; + else + if(keystate[SDLK_DOWN]) input.pad[joynum] |= INPUT_DOWN; + if(keystate[SDLK_LEFT]) input.pad[joynum] |= INPUT_LEFT; + else + if(keystate[SDLK_RIGHT]) input.pad[joynum] |= INPUT_RIGHT; + + break; + } + } + + free (keystate); + return 1; +} + + +int main (int argc, char **argv) +{ + int running = 1; + + /* Print help if no game specified */ + if(argc < 2) + { + char caption[256]; + sprintf(caption, "Genesis Plus GX\\SDL\nusage: %s gamename\n", argv[0]); + MessageBox(NULL, caption, "Information", 0); + exit(1); + } + + /* set default config */ + error_init(); + set_config_defaults(); + + /* Load ROM file */ + cart.rom = malloc(10*1024*1024); + memset(cart.rom, 0, 10*1024*1024); + if(!load_rom(argv[1])) + { + char caption[256]; + sprintf(caption, "Error loading file `%s'.", argv[1]); + MessageBox(NULL, caption, "Error", 0); + exit(1); + } + + /* load BIOS */ + memset(bios_rom, 0, sizeof(bios_rom)); + FILE *f = fopen(OS_ROM, "rb"); + if (f!=NULL) + { + fread(&bios_rom, 0x800,1,f); + fclose(f); + int i; + for(i = 0; i < 0x800; i += 2) + { + uint8 temp = bios_rom[i]; + bios_rom[i] = bios_rom[i+1]; + bios_rom[i+1] = temp; + } + config.tmss |= 2; + } + + /* initialize SDL */ + if(SDL_Init(0) < 0) + { + char caption[256]; + sprintf(caption, "SDL initialization failed"); + MessageBox(NULL, caption, "Error", 0); + exit(1); + } + sdl_video_init(); + if (use_sound) sdl_sound_init(); + sdl_sync_init(); + + /* initialize Genesis virtual system */ + SDL_LockSurface(sdl_video.surf_bitmap); + memset(&bitmap, 0, sizeof(t_bitmap)); + bitmap.width = 720; + bitmap.height = 576; +#if defined(USE_8BPP_RENDERING) + bitmap.pitch = (bitmap.width * 1); +#elif defined(USE_15BPP_RENDERING) + bitmap.pitch = (bitmap.width * 2); +#elif defined(USE_16BPP_RENDERING) + bitmap.pitch = (bitmap.width * 2); +#elif defined(USE_32BPP_RENDERING) + bitmap.pitch = (bitmap.width * 4); +#endif + bitmap.data = sdl_video.surf_bitmap->pixels; + SDL_UnlockSurface(sdl_video.surf_bitmap); + bitmap.viewport.changed = 3; + + /* initialize emulation */ + audio_init(SOUND_FREQUENCY, vdp_pal ? 50.0 : 60.0); + system_init(); + + /* load SRAM */ + f = fopen("./game.srm", "rb"); + if (f!=NULL) + { + fread(sram.sram,0x10000,1, f); + fclose(f); + } + + /* reset emulation */ + system_reset(); + + if(use_sound) SDL_PauseAudio(0); + + /* 3 frames = 50 ms (60hz) or 60 ms (50hz) */ + if(sdl_sync.sem_sync) + SDL_SetTimer(vdp_pal ? 60 : 50, sdl_sync_timer_callback); + + /* emulation loop */ + while(running) + { + SDL_Event event; + if (SDL_PollEvent(&event)) + { + switch(event.type) + { + case SDL_QUIT: + running = 0; + break; + + case SDL_KEYDOWN: + running = sdl_control_update(event.key.keysym.sym); + break; + } + } + + sdl_video_update(); + sdl_sound_update(); + + if(!turbo_mode && sdl_sync.sem_sync && sdl_video.frames_rendered % 3 == 0) + { + SDL_SemWait(sdl_sync.sem_sync); + } + + } + + /* save SRAM */ + f = fopen("./game.srm", "wb"); + if (f!=NULL) + { + fwrite(sram.sram,0x10000,1, f); + fclose(f); + } + + system_shutdown(); + audio_shutdown(); + error_shutdown(); + free(cart.rom); + + sdl_video_close(); + sdl_sound_close(); + sdl_sync_close(); + SDL_Quit(); + + return 0; +} diff --git a/source/win/main.h b/source/win/main.h new file mode 100644 index 0000000..e2e531f --- /dev/null +++ b/source/win/main.h @@ -0,0 +1,10 @@ + +#ifndef _MAIN_H_ +#define _MAIN_H_ + +#define MAX_INPUTS 8 + +extern int debug_on; +extern int log_error; + +#endif /* _MAIN_H_ */ diff --git a/source/win/md.ico b/source/win/md.ico new file mode 100644 index 0000000000000000000000000000000000000000..7cf20f88c4ce7d1b870b7e26a1d77f28df994c3c GIT binary patch literal 42126 zcmeHQ349bq)_*{P2_cejOhQ5k1Xhmh0wEk?z#)8sXwVIO;72eR3|A!JVqih!7;tq_ z(SVAmGs7ed3FOc~P*5TPxzFVWK@>TbO9Vj-Uenh1s;YaY=kCeOZxy$TOm)?(_g>Zi z)vN06SCarx2mkH*5HJscXNv$d0MH&kyYQ1!htshL>4h}6Pwl5Qg?4#OVB5BB@ci@7 zLuO_sXti2M7#E3*FTuu*8=>>dQP8-1D9oQfAFf}&4)@%154N3xxpU{jo;`b@Teogd zUS1AKuSdg@B}*V9BLiBuZVeqebbu$Hd=eHdS_CaK8bMe>efaXrFX7#H--V$=heBi| z?c-0dcI{gD%ZnO#=%I%o=8h*6!o$O%qM`yqTLiC+Gr5(0DP%z^ri>%pt9zKXnSV9S;*5ck;K@aUtDV!b&u(^6eO!-WeMa4gLs zJv|-Xd+$A@^~TQt2nq^RXady88@^M@KjkHT2U%ge*|a(Ls7H=t|Ru8@G+ul zy?ghDRwElh>+A^l^YhfBhC!1iO`z4N2#C*&fV#nTplM12X!Pg1uq_Ol-q!$H47nSk z2Qz4hi>o2z|NgJAz^eR96EFed162i1TY$nko;D2 z`1RLc;pow$@Xa^hz$>r30##L2Fl*K%esJP3Nd9=f6Zx-X4|t5>f=^4l@c zW_)A#D7EmpqT0pgcY5~;( zss&UFs1{Hypjtq+fNB9Z7U=sG#)o97>xxmx`A<&yN|WB4mnKtjZ9j=|Ws0M^$5~U; zct<*|Hv*{_ z7G*dDy@S5hjP29e4rErn!BtrE8%Z)Q%|=G=A|u6FIeDQvSk~ySm=(7fBZD;U9JAg| zL1!(MiTaEaTOy9$n^&yvx{BBTX0Ol_jw50ZtFL^)WjD)YUEpYTnh$7o>#dyseK~NM zth-`XS1!l$-J*|(p0z$pl$yYKzSr1k@r1+1*rl2akFb$k;IK93o#XudY$QdctcSTA z<_*V*66p_c+D%ErCSE@&)!Ee%hjyNZrf`Qf+MLU79cvZ#h=V-C`4xGVRV5ahaXCS# z8ek>o{F@P1Wr~y(Zlr%{tsGczz@cq-7USig9cb!+BmREgL1!!7Gmi9f&cEG9&muj! z+^UhXL9XPqOQNoHK9+6Pp-@&4N0unInTtfki*@UzO%-ctXl?L}gUsUmg2}2uQK8cz z5r<@aDy99J6T`TQ;kU<3bx7564k;=?os7oY})!&d$R2 z&yOL+mfqjS+Rnvm@%#`|#(>L=FeC#jjyEN$K1!$P-9{|mVi!9Ukojmz5 z?_6lHY17gO&hiMsX=!2eT8_gePD?>l#mDwEvDQ$VvkDJ*XyTMLw7PY(O`&y!k8y?} z+5sW$+6}RiJrt6}-Gm8Ni8r52v1j|sK^@(WyTx0zxxmqvHHs_6UR+qE&2gacYGa*M zqg06GEhC3y8nNWxoit9LMFbUU<}YWJs@- zM-22ijcCc(mabBlba8mRFI&#$P*TdSqj=-vO*`jp5rktdW=zhWXH`|*vNJE&W9{P# z@vyvgYjLSpwcfP(^y!t_S-2N}7`ab~(27bpj-PlhvwN;v*E4-YM0v+$x=wgT>6|8z zEIj9xClkMSuU|m4NAbwrn)+?$qZttFp@bx|LjN2CWp1iO1T!rr$KLmp-|vY4~KUjiYp@)Le&6j;S|O z*f)Kr6MJD{yEf77a6lt4b6!G@iqyJl0o4Mk1%AgCursDX0O^-Sscg}q1#G$531%HQb7ZmcSOsAZc>+$4QMSEAr^u_JQJ>A5R z=Z6-O>}yC zKP=!{exT*d`)F=U)f(|F%SMVkO3VAWke0m_Z{ROGVjN3i-JL~9C;GO>Uzx)gy(wWK ze;UvyWU|P*jfa3%NRs@@Lztd$kQtQodzHHBTN@q0B<0f#wAy zXWY1P;XH1}6_Af;gDj!ZJJCZFh9h$oZRw`vp`l&0#}qMGB?xu3wC+0&9UJr}LRh$H zZx+=e!?6dyfzH$OIyTaik&*bt^c)tQ;yB`(2?zG?=dbo`P^f|7I2b)*#EAPE(?Rdg zv*F0PL@66F2*8vukzJJ3k;QGA(h)EmH`<6@56Waq$>V&GjI&h7Ai~4z&r&Ti9Cc}3 zOmUPkidQDkGRINAmzG)DCN40JgL{5@2yF@>v!(gqVS9RlV8szcS+-99XEnXjKmo(C zPV85@c*a4PbL@^Mk^51}DjJoL;fP4$DIP5nM|+|EoAJ*K7J%e9s?ToR*pRu3@VL|^ zn-4KkGZte67)FWz33K!-HfG_N7Fi`6^H_iZ!*^_1Z5%7&2+`X5ri#7b(6ZR>H-s#s z{Y7A`M24g4L!P#*mf@%;tf8#pd^Ap9pdG;K$91$jn&dc0Z`!zf`ooylBh$|@R<;r) z96c$CE)2fg9E#`j@rBg)M@*+T9AxajQ4OA$B(ZZzG?@$s@08}vZ1b^zA0UW0=zhg~ zXQSwIjyQs;_}MlWF>gfb9r~7bCtQlR&c_H^-x^5=tJy%yW5m-4TBd0~jeC2Y4?#NORdL|zjrUpF-IcI)&f;-FyODP2On5KKf;dLft8kR{#xlG4VB2d) z8p6Z*K>uX(Ll0xwd~AxR3r7%bK8Tiu%;7XY+mUzuehap0z0L<=aX=a&Tua3dlGgMx ziaYWEqT?x@+@$1V@pPb!l+F#Xk949#6zZ}~g~71%t2VSzXvx+`BihWT^MZ!s*g1|m z>27pqmf|S$<2z`6IfwV7(`j|I&CB{gj)_#&mbG1;!hold;cU!wPfhvWR>u;qMsk``Hf2z!{!$Ws ziqZ^(MDpW9TJr@5$!HX|Y}turox(rDE0)6OCK?rHsz+;>PSl%?5%p-+$O&Qd$f$m- zSkKgpeho#IChlMjJPUgYMM+XGo9wc%W^_{+gj{O}rL5Sr`Kuw4@YuD>mhGVXY~+sK zQr}@m*%l&5Jo2j$FR$GZWfjNoYnuMp^AUx=t9nNzH}?;|quo)tD>qm7D_2(ekI??u z>pcEHV#7doqRvMkt?9ombw2#JVIVcA^ASjE`mgK1V?JKTzp)bF^q^$>*f-lcr@6_5 z#5NfJc5G~HYPL>db+|^2T7Z#tTE1D!!2r2!%J#fJ7} zW^)r*>1m%@hl2t_!^i@zNX3a7NJIPo8Y<&%MB5y$uAwjJA__pLG<@J#SH+QN;oqy2>{nDY zu%1;*9G21wU^~~SuA9~i4{SO)?--uPk(>iUl~Nq!$v}EmZE;vE<^;OjM~cypy!VBw z=|tPY2OQ-80tlq`I4mWJxC6&W;opYCq}4>x-?K`I3fEGn@p2!eEQCCGPvC&~fx}YL z#PL?b$A`Hh9D(#Ke{kT8*xyO4FcjiY=2<t%`fkHb>jpLS%Qe3%dN!b6_N$Z&Yup#y*;ZHn_v#1|aiJd5G* zwvN2xkm3yD`=EKOPO3GXS5J@GIoNk6b;UItY z=vX2S&z|KS2eY;AZ8&`09g@;Cr^hVcaCr7C5r=2bQiy|){I)ff?toOxb#yErad>?4 zkZ^ePEX6no8JKp;4UjU>IRNny2l=aqJgLrtRwc_yf zzTyjxd~mbaOVbwlIUnTp9&XpV4Tp#K6<=_W1~qObq`14kILM=JJxhkey=VD^BR|&- zkP64Acc1-=xc4j>4)>nr6AltH6aNahi!^MG-}B+#v*bA3?peO!7~H46%QVgLj$VuT zaO+uiINW)bZ#W#R?!H~Xl+vwXubcpCl>2`7L z<5>(m!9Plj<=^R!3U81)w!Qiq04EiNtzoz^{B$A+s*ja}HkPi~V+JZHB{wZ`G%Xx$ly3(xWa$H1D`vh%wq zn9JH9Hd`jejJH1H=3k3-d?Bng4i}!~0*CXSr5Hzc{=%AJp#w?&!bwGCmeLY)*_1wu zlO4w|O-k)?ID3{09L{@|QXHurAb(Nftsfzl=o&yx5w7pFBJ-)-*KE@wVW3w(a5#CE zD;!Rzq~38{8$38Q=A~?y*@q-26cts*WE0(@J~fBwPE}fCE}BwjvD53hKR8G$hw~1X zI9fetzaey*nb_!H4X>Q zQh=klV*J8eHH&n)Wry36{8!DTmLkiWG{}Cfe<(%bB7EhSU*XZZozu9%VZUc7!ZGw3 z9z2mnHECt|{yMj)(sI2bfz3f`+k}deiiLJl!7BdEhrMUH!C}v&1V_t4JWCM{^IS65Y%$j- zWN0ydK?ZQs&3~_g0{O-91xlP2zx|5XJj(+Pn`bG*QJ)Mhu~b@;Nqz?mjaE$4;S0!{ zxc?U4#*(WP0324&@`S^>XDPyg8&-Bgdy9EKA%m~u(@4dubnJ`MhShO(=1kiHfkO&a zdBh=ogH{oaw9ssFyU0@61fNIxSKyw@k2aU|akI(;gF|}l^N54|oj)%s!cl68CEam{ z!Ursp{W80Gut1NFn%-p!#C%AH&7N_Ho}~x}-LR4^r!4HKe0&)$@X8X$2)jL;z~JDX zNig01apkr0i?=GZHsVOl} zbA8{CpalpA3$J^_!8}VD4&1Ov19}+6PBaG&%XN(NNaL5Tfx7z-Fd1hP5`P z!ivM~?|-~D6aS~+VfflKccvww{y@*`LIM{!91lKmm!#DF^{roDks2H1vj1(?KAVIO z=0j;iF8)HxwS`XMHc8m&8aN!}N$>N4hl@`-4Iv1PMYxy&j1M zO}U{Qg-9@y)|6ure=rmCAcM(d5`~!*Rmm7|1bR|#q`a&fsuF38j5z54G{N$&`2cLW zrd*HgdNj8Yhrly7CKME#P$7=nfcBspd#Dr6aUrsuHr!J1&451OGK4g0Vr zv@@enWwdK%CaS{32aYx{1n~hB;H0vi(XR-)0F|S|)of5t*q< zlK}^Vs{|XdYj^X(b*i~)0o4Mk1%9sD7EmpqT0pgcY5~;(ss&UF Xs1{Hypjtq+fNBBN0;&amOAGuz*3qa0 literal 0 HcmV?d00001 diff --git a/source/win/osd.h b/source/win/osd.h new file mode 100644 index 0000000..2ec2e2d --- /dev/null +++ b/source/win/osd.h @@ -0,0 +1,29 @@ + +#ifndef _OSD_H_ +#define _OSD_H_ + +#include +#include +#include +#include +#include + +#include +#include + +#include "shared.h" +#include "main.h" +#include "config.h" +#include "error.h" +#include "unzip.h" +#include "fileio.h" + +#define osd_input_Update sdl_input_update + +#define GG_ROM "./ggenie.bin" +#define AR_ROM "./areplay.bin" +#define OS_ROM "./bios.bin" +#define SK_ROM "./sk.bin" +#define SK_UPMEM "./sk2chip.bin" + +#endif /* _OSD_H_ */ diff --git a/source/win/readme-sdl.txt b/source/win/readme-sdl.txt new file mode 100644 index 0000000..3c8eb64 --- /dev/null +++ b/source/win/readme-sdl.txt @@ -0,0 +1,5 @@ +Compile with MinGW. +You will also need to install the SDL library (http://www.libsdl.org/). +Zlib is required for zipped rom support. + +Please distribute required dlls with the executable. \ No newline at end of file diff --git a/source/win/unzip.c b/source/win/unzip.c new file mode 100644 index 0000000..ef52bc6 --- /dev/null +++ b/source/win/unzip.c @@ -0,0 +1,1294 @@ +/* unzip.c -- IO on .zip files using zlib + Version 0.15 beta, Mar 19th, 1998, + + Read unzip.h for more info +*/ + + +#include +#include +#include +#include +#include "unzip.h" + +#ifdef STDC +# include +# include +# include +#endif +#ifdef NO_ERRNO_H + extern int errno; +#else + #include +#endif + + +#ifndef local + #define local static +#endif +/* compile with -Dlocal if your debugger can't find static symbols */ + + + +#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ + !defined(CASESENSITIVITYDEFAULT_NO) +#define CASESENSITIVITYDEFAULT_NO +#endif + + +#ifndef UNZ_BUFSIZE +#define UNZ_BUFSIZE (16384) +#endif + +#ifndef UNZ_MAXFILENAMEINZIP +#define UNZ_MAXFILENAMEINZIP (256) +#endif + +#ifndef ALLOC +# define ALLOC(size) (malloc(size)) +#endif +#ifndef TRYFREE +# define TRYFREE(p) {if (p) free(p);} +#endif + +#define SIZECENTRALDIRITEM (0x2e) +#define SIZEZIPLOCALHEADER (0x1e) + +/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ + +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif + +#ifndef SEEK_END +#define SEEK_END 2 +#endif + +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + +const char unz_copyright[] = + " unzip 0.15 Copyright 1998 Gilles Vollant "; + +/* unz_file_info_interntal contain internal info about a file in zipfile*/ +typedef struct unz_file_info_internal_s +{ + uLong offset_curfile;/* relative offset of local header 4 bytes */ +} unz_file_info_internal; + + +/* file_in_zip_read_info_s contain internal information about a file in zipfile, + when reading and decompress it */ +typedef struct +{ + char *read_buffer; /* internal buffer for compressed data */ + z_stream stream; /* zLib stream structure for inflate */ + + uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ + uLong stream_initialised; /* flag set if stream structure is initialised*/ + + uLong offset_local_extrafield;/* offset of the local extra field */ + uInt size_local_extrafield;/* size of the local extra field */ + uLong pos_local_extrafield; /* position in the local extra field in read*/ + + uLong crc32; /* crc32 of all data uncompressed */ + uLong crc32_wait; /* crc32 we must obtain after decompress all */ + uLong rest_read_compressed; /* number of byte to be decompressed */ + uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ + FILE* file; /* io structore of the zipfile */ + uLong compression_method; /* compression method (0==store) */ + uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ +} file_in_zip_read_info_s; + + +/* unz_s contain internal information about the zipfile +*/ +typedef struct +{ + FILE* file; /* io structore of the zipfile */ + unz_global_info gi; /* public global information */ + uLong byte_before_the_zipfile; /* byte before the zipfile, (>0 for sfx)*/ + uLong num_file; /* number of the current file in the zipfile*/ + uLong pos_in_central_dir; /* pos of the current file in the central dir*/ + uLong current_file_ok; /* flag about the usability of the current file*/ + uLong central_pos; /* position of the beginning of the central dir*/ + + uLong size_central_dir; /* size of the central directory */ + uLong offset_central_dir; /* offset of start of central directory with + respect to the starting disk number */ + + unz_file_info cur_file_info; /* public info about the current file in zip*/ + unz_file_info_internal cur_file_info_internal; /* private info about it*/ + file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current + file if we are decompressing it */ +} unz_s; + + +/* =========================================================================== + Read a byte from a gz_stream; update next_in and avail_in. Return EOF + for end of file. + IN assertion: the stream s has been sucessfully opened for reading. +*/ + + +local int unzlocal_getByte(fin,pi) + FILE *fin; + int *pi; +{ + unsigned char c; + int err = fread(&c, 1, 1, fin); + if (err==1) + { + *pi = (int)c; + return UNZ_OK; + } + else + { + if (ferror(fin)) + return UNZ_ERRNO; + else + return UNZ_EOF; + } +} + + +/* =========================================================================== + Reads a long in LSB order from the given gz_stream. Sets +*/ +local int unzlocal_getShort (fin,pX) + FILE* fin; + uLong *pX; +{ + uLong x ; + int i = 0; + int err; + + err = unzlocal_getByte(fin,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + +local int unzlocal_getLong (fin,pX) + FILE* fin; + uLong *pX; +{ + uLong x ; + int i = 0; + int err; + + err = unzlocal_getByte(fin,&i); + x = (uLong)i; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<8; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<16; + + if (err==UNZ_OK) + err = unzlocal_getByte(fin,&i); + x += ((uLong)i)<<24; + + if (err==UNZ_OK) + *pX = x; + else + *pX = 0; + return err; +} + + +/* My own strcmpi / strcasecmp */ +local int strcmpcasenosensitive_internal (fileName1,fileName2) + const char* fileName1; + const char* fileName2; +{ + for (;;) + { + char c1=*(fileName1++); + char c2=*(fileName2++); + if ((c1>='a') && (c1<='z')) + c1 -= 0x20; + if ((c2>='a') && (c2<='z')) + c2 -= 0x20; + if (c1=='\0') + return ((c2=='\0') ? 0 : -1); + if (c2=='\0') + return 1; + if (c1c2) + return 1; + } +} + + +#ifdef CASESENSITIVITYDEFAULT_NO +#define CASESENSITIVITYDEFAULTVALUE 2 +#else +#define CASESENSITIVITYDEFAULTVALUE 1 +#endif + +#ifndef STRCMPCASENOSENTIVEFUNCTION +#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal +#endif + +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) + +*/ +extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) + const char* fileName1; + const char* fileName2; + int iCaseSensitivity; +{ + if (iCaseSensitivity==0) + iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; + + if (iCaseSensitivity==1) + return strcmp(fileName1,fileName2); + + return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); +} + +#define BUFREADCOMMENT (0x400) + +/* + Locate the Central directory of a zipfile (at the end, just before + the global comment) +*/ +local uLong unzlocal_SearchCentralDir(fin) + FILE *fin; +{ + unsigned char* buf; + uLong uSizeFile; + uLong uBackRead; + uLong uMaxBack=0xffff; /* maximum size of global comment */ + uLong uPosFound=0; + + if (fseek(fin,0,SEEK_END) != 0) + return 0; + + + uSizeFile = ftell( fin ); + + if (uMaxBack>uSizeFile) + uMaxBack = uSizeFile; + + buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); + if (buf==NULL) + return 0; + + uBackRead = 4; + while (uBackReaduMaxBack) + uBackRead = uMaxBack; + else + uBackRead+=BUFREADCOMMENT; + uReadPos = uSizeFile-uBackRead ; + + uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? + (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); + if (fseek(fin,uReadPos,SEEK_SET)!=0) + break; + + if (fread(buf,(uInt)uReadSize,1,fin)!=1) + break; + + for (i=(int)uReadSize-3; (i--)>0;) + if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && + ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) + { + uPosFound = uReadPos+i; + break; + } + + if (uPosFound!=0) + break; + } + TRYFREE(buf); + return uPosFound; +} + +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer + "zlib/zlib109.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ +extern unzFile ZEXPORT unzOpen (path) + const char *path; +{ + unz_s us; + unz_s *s; + uLong central_pos,uL; + FILE * fin ; + + uLong number_disk; /* number of the current dist, used for + spaning ZIP, unsupported, always 0*/ + uLong number_disk_with_CD; /* number the the disk with central dir, used + for spaning ZIP, unsupported, always 0*/ + uLong number_entry_CD; /* total number of entries in + the central dir + (same than number_entry on nospan) */ + + int err=UNZ_OK; + + if (unz_copyright[0]!=' ') + return NULL; + + fin=fopen(path,"rb"); + if (fin==NULL) + return NULL; + + central_pos = unzlocal_SearchCentralDir(fin); + if (central_pos==0) + err=UNZ_ERRNO; + + if (fseek(fin,central_pos,SEEK_SET)!=0) + err=UNZ_ERRNO; + + /* the signature, already checked */ + if (unzlocal_getLong(fin,&uL)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of this disk */ + if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) + err=UNZ_ERRNO; + + /* number of the disk with the start of the central directory */ + if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir on this disk */ + if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) + err=UNZ_ERRNO; + + /* total number of entries in the central dir */ + if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((number_entry_CD!=us.gi.number_entry) || + (number_disk_with_CD!=0) || + (number_disk!=0)) + err=UNZ_BADZIPFILE; + + /* size of the central directory */ + if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* offset of start of central directory with respect to the + starting disk number */ + if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) + err=UNZ_ERRNO; + + /* zipfile comment length */ + if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) + err=UNZ_ERRNO; + + if ((central_pospfile_in_zip_read!=NULL) + unzCloseCurrentFile(file); + + fclose(s->file); + TRYFREE(s); + return UNZ_OK; +} + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ +extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) + unzFile file; + unz_global_info *pglobal_info; +{ + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + *pglobal_info=s->gi; + return UNZ_OK; +} + + +/* + Translate date/time from Dos format to tm_unz (readable more easilty) +*/ +local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) + uLong ulDosDate; + tm_unz* ptm; +{ + uLong uDate; + uDate = (uLong)(ulDosDate>>16); + ptm->tm_mday = (uInt)(uDate&0x1f) ; + ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; + ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; + + ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); + ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; + ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; +} + +/* + Get Info about the current file in the zipfile, with internal only info +*/ +local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, + unz_file_info *pfile_info, + unz_file_info_internal + *pfile_info_internal, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); + +local int unzlocal_GetCurrentFileInfoInternal (file, + pfile_info, + pfile_info_internal, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) + unzFile file; + unz_file_info *pfile_info; + unz_file_info_internal *pfile_info_internal; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; +{ + unz_s* s; + unz_file_info file_info; + unz_file_info_internal file_info_internal; + int err=UNZ_OK; + uLong uMagic; + long lSeek=0; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) + err=UNZ_ERRNO; + + + /* we check the magic */ + if (err==UNZ_OK) + { + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x02014b50) + err=UNZ_BADZIPFILE; + } + + if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) + err=UNZ_ERRNO; + + unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); + + if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) + err=UNZ_ERRNO; + + lSeek+=file_info.size_filename; + if ((err==UNZ_OK) && (szFileName!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_filename0) && (fileNameBufferSize>0)) + if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek -= uSizeRead; + } + + if ((err==UNZ_OK) && (extraField!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + + if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) + if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek += file_info.size_file_extra - uSizeRead; + } + else + lSeek+=file_info.size_file_extra; + + if ((err==UNZ_OK) && (szComment!=NULL)) + { + uLong uSizeRead ; + if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) + lSeek=0; + else + err=UNZ_ERRNO; + } + + if ((file_info.size_file_comment>0) && (commentBufferSize>0)) + if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) + err=UNZ_ERRNO; + lSeek+=file_info.size_file_comment - uSizeRead; + } + else + lSeek+=file_info.size_file_comment; + + if ((err==UNZ_OK) && (pfile_info!=NULL)) + *pfile_info=file_info; + + if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) + *pfile_info_internal=file_info_internal; + + return err; +} + + + +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. +*/ +extern int ZEXPORT unzGetCurrentFileInfo (file, + pfile_info, + szFileName, fileNameBufferSize, + extraField, extraFieldBufferSize, + szComment, commentBufferSize) + unzFile file; + unz_file_info *pfile_info; + char *szFileName; + uLong fileNameBufferSize; + void *extraField; + uLong extraFieldBufferSize; + char *szComment; + uLong commentBufferSize; +{ + return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, + szFileName,fileNameBufferSize, + extraField,extraFieldBufferSize, + szComment,commentBufferSize); +} + +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ +extern int ZEXPORT unzGoToFirstFile (file) + unzFile file; +{ + int err=UNZ_OK; + unz_s* s; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + s->pos_in_central_dir=s->offset_central_dir; + s->num_file=0; + err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ +extern int ZEXPORT unzGoToNextFile (file) + unzFile file; +{ + unz_s* s; + int err; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + if (s->num_file+1==s->gi.number_entry) + return UNZ_END_OF_LIST_OF_FILE; + + s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + + s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; + s->num_file++; + err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, + &s->cur_file_info_internal, + NULL,0,NULL,0,NULL,0); + s->current_file_ok = (err == UNZ_OK); + return err; +} + + +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzipStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ +extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) + unzFile file; + const char *szFileName; + int iCaseSensitivity; +{ + unz_s* s; + int err; + + uLong num_fileSaved; + uLong pos_in_central_dirSaved; + + if (file==NULL) + return UNZ_PARAMERROR; + + if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) + return UNZ_PARAMERROR; + + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_END_OF_LIST_OF_FILE; + + num_fileSaved = s->num_file; + pos_in_central_dirSaved = s->pos_in_central_dir; + + err = unzGoToFirstFile(file); + + while (err == UNZ_OK) + { + char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; + unzGetCurrentFileInfo(file,NULL, + szCurrentFileName,sizeof(szCurrentFileName)-1, + NULL,0,NULL,0); + if (unzStringFileNameCompare(szCurrentFileName, + szFileName,iCaseSensitivity)==0) + return UNZ_OK; + err = unzGoToNextFile(file); + } + + s->num_file = num_fileSaved ; + s->pos_in_central_dir = pos_in_central_dirSaved ; + return err; +} + + +/* + Read the local header of the current zipfile + Check the coherency of the local header and info in the end of central + directory about this file + store in *piSizeVar the size of extra info in local header + (filename and size of extra field data) +*/ +local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, + poffset_local_extrafield, + psize_local_extrafield) + unz_s* s; + uInt* piSizeVar; + uLong *poffset_local_extrafield; + uInt *psize_local_extrafield; +{ + uLong uMagic,uData,uFlags; + uLong size_filename; + uLong size_extra_field; + int err=UNZ_OK; + + *piSizeVar = 0; + *poffset_local_extrafield = 0; + *psize_local_extrafield = 0; + + if (fseek(s->file,s->cur_file_info_internal.offset_curfile + + s->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; + + + if (err==UNZ_OK) + { + if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) + err=UNZ_ERRNO; + else if (uMagic!=0x04034b50) + err=UNZ_BADZIPFILE; + } + + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; +/* + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) + err=UNZ_BADZIPFILE; +*/ + if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) + err=UNZ_ERRNO; + + if (unzlocal_getShort(s->file,&uData) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) + err=UNZ_BADZIPFILE; + + if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ + err=UNZ_ERRNO; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && + ((uFlags & 8)==0)) + err=UNZ_BADZIPFILE; + + + if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) + err=UNZ_ERRNO; + else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) + err=UNZ_BADZIPFILE; + + *piSizeVar += (uInt)size_filename; + + if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) + err=UNZ_ERRNO; + *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + + SIZEZIPLOCALHEADER + size_filename; + *psize_local_extrafield = (uInt)size_extra_field; + + *piSizeVar += (uInt)size_extra_field; + + return err; +} + +/* + Open for reading data the current file in the zipfile. + If there is no error and the file is opened, the return value is UNZ_OK. +*/ +extern int ZEXPORT unzOpenCurrentFile (file) + unzFile file; +{ + int err=UNZ_OK; + int Store; + uInt iSizeVar; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uLong offset_local_extrafield; /* offset of the local extra field */ + uInt size_local_extrafield; /* size of the local extra field */ + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + if (!s->current_file_ok) + return UNZ_PARAMERROR; + + if (s->pfile_in_zip_read != NULL) + unzCloseCurrentFile(file); + + if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, + &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) + return UNZ_BADZIPFILE; + + pfile_in_zip_read_info = (file_in_zip_read_info_s*) + ALLOC(sizeof(file_in_zip_read_info_s)); + if (pfile_in_zip_read_info==NULL) + return UNZ_INTERNALERROR; + + pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); + pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; + pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; + pfile_in_zip_read_info->pos_local_extrafield=0; + + if (pfile_in_zip_read_info->read_buffer==NULL) + { + TRYFREE(pfile_in_zip_read_info); + return UNZ_INTERNALERROR; + } + + pfile_in_zip_read_info->stream_initialised=0; + + if ((s->cur_file_info.compression_method!=0) && + (s->cur_file_info.compression_method!=Z_DEFLATED)) + err=UNZ_BADZIPFILE; + Store = s->cur_file_info.compression_method==0; + + pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; + pfile_in_zip_read_info->crc32=0; + pfile_in_zip_read_info->compression_method = + s->cur_file_info.compression_method; + pfile_in_zip_read_info->file=s->file; + pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; + + pfile_in_zip_read_info->stream.total_out = 0; + + if (!Store) + { + pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; + pfile_in_zip_read_info->stream.zfree = (free_func)0; + pfile_in_zip_read_info->stream.opaque = (voidpf)0; + + err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); + if (err == Z_OK) + pfile_in_zip_read_info->stream_initialised=1; + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. + * In unzip, i don't wait absolutely Z_STREAM_END because I known the + * size of both compressed and uncompressed data + */ + } + pfile_in_zip_read_info->rest_read_compressed = + s->cur_file_info.compressed_size ; + pfile_in_zip_read_info->rest_read_uncompressed = + s->cur_file_info.uncompressed_size ; + + pfile_in_zip_read_info->pos_in_zipfile = + s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + + iSizeVar; + + pfile_in_zip_read_info->stream.avail_in = (uInt)0; + + + s->pfile_in_zip_read = pfile_in_zip_read_info; + return UNZ_OK; +} + + +/* + Read bytes from the current file. + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ +extern int ZEXPORT unzReadCurrentFile (file, buf, len) + unzFile file; + voidp buf; + unsigned len; +{ + int err=UNZ_OK; + uInt iRead = 0; + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if ((pfile_in_zip_read_info->read_buffer == NULL)) + return UNZ_END_OF_LIST_OF_FILE; + if (len==0) + return 0; + + pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; + + pfile_in_zip_read_info->stream.avail_out = (uInt)len; + + if (len>pfile_in_zip_read_info->rest_read_uncompressed) + pfile_in_zip_read_info->stream.avail_out = + (uInt)pfile_in_zip_read_info->rest_read_uncompressed; + + while (pfile_in_zip_read_info->stream.avail_out>0) + { + if ((pfile_in_zip_read_info->stream.avail_in==0) && + (pfile_in_zip_read_info->rest_read_compressed>0)) + { + uInt uReadThis = UNZ_BUFSIZE; + if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; + if (uReadThis == 0) + return UNZ_EOF; + if (fseek(pfile_in_zip_read_info->file, + pfile_in_zip_read_info->pos_in_zipfile + + pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) + return UNZ_ERRNO; + if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, + pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; + pfile_in_zip_read_info->pos_in_zipfile += uReadThis; + + pfile_in_zip_read_info->rest_read_compressed-=uReadThis; + + pfile_in_zip_read_info->stream.next_in = + (Bytef*)pfile_in_zip_read_info->read_buffer; + pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; + } + + if (pfile_in_zip_read_info->compression_method==0) + { + uInt uDoCopy,i ; + if (pfile_in_zip_read_info->stream.avail_out < + pfile_in_zip_read_info->stream.avail_in) + uDoCopy = pfile_in_zip_read_info->stream.avail_out ; + else + uDoCopy = pfile_in_zip_read_info->stream.avail_in ; + + for (i=0;istream.next_out+i) = + *(pfile_in_zip_read_info->stream.next_in+i); + + pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, + pfile_in_zip_read_info->stream.next_out, + uDoCopy); + pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; + pfile_in_zip_read_info->stream.avail_in -= uDoCopy; + pfile_in_zip_read_info->stream.avail_out -= uDoCopy; + pfile_in_zip_read_info->stream.next_out += uDoCopy; + pfile_in_zip_read_info->stream.next_in += uDoCopy; + pfile_in_zip_read_info->stream.total_out += uDoCopy; + iRead += uDoCopy; + } + else + { + uLong uTotalOutBefore,uTotalOutAfter; + const Bytef *bufBefore; + uLong uOutThis; + int flush=Z_SYNC_FLUSH; + + uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; + bufBefore = pfile_in_zip_read_info->stream.next_out; + + /* + if ((pfile_in_zip_read_info->rest_read_uncompressed == + pfile_in_zip_read_info->stream.avail_out) && + (pfile_in_zip_read_info->rest_read_compressed == 0)) + flush = Z_FINISH; + */ + err=inflate(&pfile_in_zip_read_info->stream,flush); + + uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; + uOutThis = uTotalOutAfter-uTotalOutBefore; + + pfile_in_zip_read_info->crc32 = + crc32(pfile_in_zip_read_info->crc32,bufBefore, + (uInt)(uOutThis)); + + pfile_in_zip_read_info->rest_read_uncompressed -= + uOutThis; + + iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); + + if (err==Z_STREAM_END) + return (iRead==0) ? UNZ_EOF : iRead; + if (err!=Z_OK) + break; + } + } + + if (err==Z_OK) + return iRead; + return err; +} + + +/* + Give the current position in uncompressed data +*/ +extern z_off_t ZEXPORT unztell (file) + unzFile file; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + return (z_off_t)pfile_in_zip_read_info->stream.total_out; +} + + +/* + return 1 if the end of file was reached, 0 elsewhere +*/ +extern int ZEXPORT unzeof (file) + unzFile file; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + return 1; + else + return 0; +} + +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field that can be read + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ +extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) + unzFile file; + voidp buf; + unsigned len; +{ + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + uInt read_now; + uLong size_to_read; + + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + size_to_read = (pfile_in_zip_read_info->size_local_extrafield - + pfile_in_zip_read_info->pos_local_extrafield); + + if (buf==NULL) + return (int)size_to_read; + + if (len>size_to_read) + read_now = (uInt)size_to_read; + else + read_now = (uInt)len ; + + if (read_now==0) + return 0; + + if (fseek(pfile_in_zip_read_info->file, + pfile_in_zip_read_info->offset_local_extrafield + + pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) + return UNZ_ERRNO; + + if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) + return UNZ_ERRNO; + + return (int)read_now; +} + +/* + Close the file in zip opened with unzipOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ +extern int ZEXPORT unzCloseCurrentFile (file) + unzFile file; +{ + int err=UNZ_OK; + + unz_s* s; + file_in_zip_read_info_s* pfile_in_zip_read_info; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + pfile_in_zip_read_info=s->pfile_in_zip_read; + + if (pfile_in_zip_read_info==NULL) + return UNZ_PARAMERROR; + + + if (pfile_in_zip_read_info->rest_read_uncompressed == 0) + { + if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) + err=UNZ_CRCERROR; + } + + + TRYFREE(pfile_in_zip_read_info->read_buffer); + pfile_in_zip_read_info->read_buffer = NULL; + if (pfile_in_zip_read_info->stream_initialised) + inflateEnd(&pfile_in_zip_read_info->stream); + + pfile_in_zip_read_info->stream_initialised = 0; + TRYFREE(pfile_in_zip_read_info); + + s->pfile_in_zip_read=NULL; + + return err; +} + + +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ +extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) + unzFile file; + char *szComment; + uLong uSizeBuf; +{ +/* int err=UNZ_OK; */ + unz_s* s; + uLong uReadThis ; + if (file==NULL) + return UNZ_PARAMERROR; + s=(unz_s*)file; + + uReadThis = uSizeBuf; + if (uReadThis>s->gi.size_comment) + uReadThis = s->gi.size_comment; + + if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) + return UNZ_ERRNO; + + if (uReadThis>0) + { + *szComment='\0'; + if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) + return UNZ_ERRNO; + } + + if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) + *(szComment+s->gi.size_comment)='\0'; + return (int)uReadThis; +} diff --git a/source/win/unzip.h b/source/win/unzip.h new file mode 100644 index 0000000..a30f79c --- /dev/null +++ b/source/win/unzip.h @@ -0,0 +1,273 @@ +/* unzip.h -- IO for uncompress .zip files using zlib + Version 0.15 beta, Mar 19th, 1998, + + Copyright (C) 1998 Gilles Vollant + + This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g + WinZip, InfoZip tools and compatible. + Encryption and multi volume ZipFile (span) are not supported. + Old compressions used by old PKZip 1.x are not supported + + THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE + CAN CHANGE IN FUTURE VERSION !! + I WAIT FEEDBACK at mail info@winimage.com + Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution + + Condition of use and distribution are the same than zlib : + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* for more info about .ZIP format, see + ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip + PkWare has also a specification at : + ftp://ftp.pkware.com/probdesc.zip */ + +#ifndef _unz_H +#define _unz_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _ZLIB_H +#include "zlib.h" +#endif + +#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) +/* like the STRICT of WIN32, we define a pointer that cannot be converted + from (void*) without cast */ +typedef struct TagunzFile__ { int unused; } unzFile__; +typedef unzFile__ *unzFile; +#else +typedef voidp unzFile; +#endif + + +#define UNZ_OK (0) +#define UNZ_END_OF_LIST_OF_FILE (-100) +#define UNZ_ERRNO (Z_ERRNO) +#define UNZ_EOF (0) +#define UNZ_PARAMERROR (-102) +#define UNZ_BADZIPFILE (-103) +#define UNZ_INTERNALERROR (-104) +#define UNZ_CRCERROR (-105) + +/* tm_unz contain date/time info */ +typedef struct tm_unz_s +{ + uInt tm_sec; /* seconds after the minute - [0,59] */ + uInt tm_min; /* minutes after the hour - [0,59] */ + uInt tm_hour; /* hours since midnight - [0,23] */ + uInt tm_mday; /* day of the month - [1,31] */ + uInt tm_mon; /* months since January - [0,11] */ + uInt tm_year; /* years - [1980..2044] */ +} tm_unz; + +/* unz_global_info structure contain global data about the ZIPfile + These data comes from the end of central dir */ +typedef struct unz_global_info_s +{ + uLong number_entry; /* total number of entries in + the central dir on this disk */ + uLong size_comment; /* size of the global comment of the zipfile */ +} unz_global_info; + + +/* unz_file_info contain information about a file in the zipfile */ +typedef struct unz_file_info_s +{ + uLong version; /* version made by 2 bytes */ + uLong version_needed; /* version needed to extract 2 bytes */ + uLong flag; /* general purpose bit flag 2 bytes */ + uLong compression_method; /* compression method 2 bytes */ + uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ + uLong crc; /* crc-32 4 bytes */ + uLong compressed_size; /* compressed size 4 bytes */ + uLong uncompressed_size; /* uncompressed size 4 bytes */ + uLong size_filename; /* filename length 2 bytes */ + uLong size_file_extra; /* extra field length 2 bytes */ + uLong size_file_comment; /* file comment length 2 bytes */ + + uLong disk_num_start; /* disk number start 2 bytes */ + uLong internal_fa; /* internal file attributes 2 bytes */ + uLong external_fa; /* external file attributes 4 bytes */ + + tm_unz tmu_date; +} unz_file_info; + +extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, + const char* fileName2, + int iCaseSensitivity)); +/* + Compare two filename (fileName1,fileName2). + If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) + If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi + or strcasecmp) + If iCaseSenisivity = 0, case sensitivity is defaut of your operating system + (like 1 on Unix, 2 on Windows) +*/ + + +extern unzFile ZEXPORT unzOpen OF((const char *path)); +/* + Open a Zip file. path contain the full pathname (by example, + on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer + "zlib/zlib111.zip". + If the zipfile cannot be opened (file don't exist or in not valid), the + return value is NULL. + Else, the return value is a unzFile Handle, usable with other function + of this unzip package. +*/ + +extern int ZEXPORT unzClose OF((unzFile file)); +/* + Close a ZipFile opened with unzipOpen. + If there is files inside the .Zip opened with unzOpenCurrentFile (see later), + these files MUST be closed with unzipCloseCurrentFile before call unzipClose. + return UNZ_OK if there is no problem. */ + +extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, + unz_global_info *pglobal_info)); +/* + Write info about the ZipFile in the *pglobal_info structure. + No preparation of the structure is needed + return UNZ_OK if there is no problem. */ + + +extern int ZEXPORT unzGetGlobalComment OF((unzFile file, + char *szComment, + uLong uSizeBuf)); +/* + Get the global comment string of the ZipFile, in the szComment buffer. + uSizeBuf is the size of the szComment buffer. + return the number of byte copied or an error code <0 +*/ + + +/***************************************************************************/ +/* Unzip package allow you browse the directory of the zipfile */ + +extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); +/* + Set the current file of the zipfile to the first file. + return UNZ_OK if there is no problem +*/ + +extern int ZEXPORT unzGoToNextFile OF((unzFile file)); +/* + Set the current file of the zipfile to the next file. + return UNZ_OK if there is no problem + return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. +*/ + +extern int ZEXPORT unzLocateFile OF((unzFile file, + const char *szFileName, + int iCaseSensitivity)); +/* + Try locate the file szFileName in the zipfile. + For the iCaseSensitivity signification, see unzStringFileNameCompare + + return value : + UNZ_OK if the file is found. It becomes the current file. + UNZ_END_OF_LIST_OF_FILE if the file is not found +*/ + + +extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, + unz_file_info *pfile_info, + char *szFileName, + uLong fileNameBufferSize, + void *extraField, + uLong extraFieldBufferSize, + char *szComment, + uLong commentBufferSize)); +/* + Get Info about the current file + if pfile_info!=NULL, the *pfile_info structure will contain somes info about + the current file + if szFileName!=NULL, the filemane string will be copied in szFileName + (fileNameBufferSize is the size of the buffer) + if extraField!=NULL, the extra field information will be copied in extraField + (extraFieldBufferSize is the size of the buffer). + This is the Central-header version of the extra field + if szComment!=NULL, the comment string of the file will be copied in szComment + (commentBufferSize is the size of the buffer) +*/ + +/***************************************************************************/ +/* for reading the content of the current zipfile, you can open it, read data + from it, and close it (you can close it before reading all the file) + */ + +extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); +/* + Open for reading data the current file in the zipfile. + If there is no error, the return value is UNZ_OK. +*/ + +extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); +/* + Close the file in zip opened with unzOpenCurrentFile + Return UNZ_CRCERROR if all the file was read but the CRC is not good +*/ + +extern int ZEXPORT unzReadCurrentFile OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read bytes from the current file (opened by unzOpenCurrentFile) + buf contain buffer where data must be copied + len the size of buf. + + return the number of byte copied if somes bytes are copied + return 0 if the end of file was reached + return <0 with error code if there is an error + (UNZ_ERRNO for IO error, or zLib error for uncompress error) +*/ + +extern z_off_t ZEXPORT unztell OF((unzFile file)); +/* + Give the current position in uncompressed data +*/ + +extern int ZEXPORT unzeof OF((unzFile file)); +/* + return 1 if the end of file was reached, 0 elsewhere +*/ + +extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, + voidp buf, + unsigned len)); +/* + Read extra field from the current file (opened by unzOpenCurrentFile) + This is the local-header version of the extra field (sometimes, there is + more info in the local-header version than in the central-header) + + if buf==NULL, it return the size of the local extra field + + if buf!=NULL, len is the size of the buffer, the extra header is copied in + buf. + the return value is the number of bytes copied in buf, or (if <0) + the error code +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* _unz_H */ diff --git a/source/z80/z80.c b/source/z80/z80.c index 2e13587..53dacf3 100644 --- a/source/z80/z80.c +++ b/source/z80/z80.c @@ -135,7 +135,6 @@ #define LOG(x) #endif - #define cpu_readop(a) z80_readmap[(a) >> 10][(a) & 0x03FF] #define cpu_readop_arg(a) z80_readmap[(a) >> 10][(a) & 0x03FF] @@ -208,7 +207,7 @@ unsigned char *z80_readmap[64]; unsigned char *z80_writemap[64]; void (*z80_writemem)(unsigned int address, unsigned char data); -unsigned char (*z80_readmem)(unsigned int port); +unsigned char (*z80_readmem)(unsigned int address); void (*z80_writeport)(unsigned int port, unsigned char data); unsigned char (*z80_readport)(unsigned int port); @@ -3420,7 +3419,7 @@ void z80_run(unsigned int cycles) while( mcycles_z80 < cycles ) { /* check for IRQs before each instruction */ - if ((Z80.irq_state & 7) && IFF1 && !Z80.after_ei) + if (Z80.irq_state && IFF1 && !Z80.after_ei) { take_interrupt(); if (mcycles_z80 >= cycles) return; @@ -3465,9 +3464,14 @@ void z80_set_context (void *src) } /**************************************************************************** - * Set IRQ line state + * Set IRQ lines ****************************************************************************/ -void z80_set_nmi_line(int state) +void z80_set_irq_line(unsigned int state) +{ + Z80.irq_state = state; +} + +void z80_set_nmi_line(unsigned int state) { /* mark an NMI pending on the rising edge */ if (Z80.nmi_state == CLEAR_LINE && state != CLEAR_LINE) diff --git a/source/z80/z80.h b/source/z80/z80.h index c3a3ea4..46e64da 100644 --- a/source/z80/z80.h +++ b/source/z80/z80.h @@ -54,7 +54,7 @@ extern unsigned char *z80_readmap[64]; extern unsigned char *z80_writemap[64]; extern void (*z80_writemem)(unsigned int address, unsigned char data); -extern unsigned char (*z80_readmem)(unsigned int port); +extern unsigned char (*z80_readmem)(unsigned int address); extern void (*z80_writeport)(unsigned int port, unsigned char data); extern unsigned char (*z80_readport)(unsigned int port); @@ -65,7 +65,8 @@ extern void z80_run(unsigned int cycles); extern void z80_burn(unsigned int cycles); extern void z80_get_context (void *dst); extern void z80_set_context (void *src); -extern void z80_set_nmi_line(int state); +extern void z80_set_irq_line(unsigned int state); +extern void z80_set_nmi_line(unsigned int state); #endif