mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-25 18:51:49 +01:00
----------------------
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.
This commit is contained in:
parent
651e91ece6
commit
62f1204476
440
LICENSE.txt
440
LICENSE.txt
@ -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' <www.elotrolado.net>
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin 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.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
133
Makefile.win32
Normal file
133
Makefile.win32
Normal file
@ -0,0 +1,133 @@
|
||||
|
||||
# Makefile for genplus SDL
|
||||
#
|
||||
# (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald
|
||||
# modified by Eke-Eke <eke_eke31@yahoo.fr>
|
||||
#
|
||||
# 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)
|
@ -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"
|
||||
|
||||
|
@ -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_
|
||||
|
@ -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<GAME_CNT)
|
||||
{
|
||||
if (strstr(rominfo.product,database[i].game_id) != NULL)
|
||||
{
|
||||
/* additional check (Micro Machines, Rockman Mega World) */
|
||||
if ((database[i].chk == 0) || (database[i].chk == rominfo.checksum))
|
||||
{
|
||||
sram.custom = 1;
|
||||
sram.on = 1;
|
||||
memcpy(&eeprom.type, &database[i].type, sizeof(T_EEPROM_TYPE));
|
||||
return;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Game not found in database but header seems to indicate it uses EEPROM */
|
||||
if (sram.detected)
|
||||
{
|
||||
if ((sram.end - sram.start) < 2)
|
||||
{
|
||||
/* set SEGA mapper as default */
|
||||
sram.custom = 1;
|
||||
memcpy(&eeprom.type, &database[9].type, sizeof(T_EEPROM_TYPE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void Detect_START()
|
||||
{
|
||||
if (eeprom.old_scl && eeprom.scl)
|
||||
{
|
||||
if (eeprom.old_sda && !eeprom.sda)
|
||||
{
|
||||
eeprom.cycles = 0;
|
||||
eeprom.slave_mask = 0;
|
||||
if (eeprom.type.address_bits == 7)
|
||||
{
|
||||
eeprom.word_address = 0;
|
||||
eeprom.state = GET_WORD_ADR_7BITS;
|
||||
}
|
||||
else eeprom.state = GET_SLAVE_ADR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void Detect_STOP()
|
||||
{
|
||||
if (eeprom.old_scl && eeprom.scl)
|
||||
{
|
||||
if (!eeprom.old_sda && eeprom.sda)
|
||||
{
|
||||
eeprom.state = STAND_BY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_write(unsigned int address, unsigned int data, int word_access)
|
||||
{
|
||||
/* decode SCL and SDA value */
|
||||
if (word_access)
|
||||
{
|
||||
/* 16-bits access */
|
||||
if (eeprom.type.sda_in_adr == address) eeprom.sda = (data >> (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);
|
||||
}
|
259
source/cart_hw/gg_eeprom.c
Normal file
259
source/cart_hw/gg_eeprom.c
Normal file
@ -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));
|
||||
}
|
||||
|
75
source/cart_hw/gg_eeprom.h
Normal file
75
source/cart_hw/gg_eeprom.h
Normal file
@ -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
|
@ -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
|
||||
|
@ -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_
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
554
source/cart_hw/md_eeprom.c
Normal file
554
source/cart_hw/md_eeprom.c
Normal file
@ -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<GAME_CNT)
|
||||
{
|
||||
if (strstr(rominfo.product,database[i].game_id) != NULL)
|
||||
{
|
||||
/* additional check (Micro Machines, Rockman Mega World) */
|
||||
if ((database[i].chk == 0) || (database[i].chk == rominfo.checksum))
|
||||
{
|
||||
sram.custom = 1;
|
||||
sram.on = 1;
|
||||
memcpy(&md_eeprom.type, &database[i].type, sizeof(T_EEPROM_TYPE));
|
||||
return;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Game not found in database but header seems to indicate it uses EEPROM */
|
||||
if (sram.detected)
|
||||
{
|
||||
if ((sram.end - sram.start) < 2)
|
||||
{
|
||||
/* set SEGA mapper as default */
|
||||
sram.custom = 1;
|
||||
memcpy(&md_eeprom.type, &database[9].type, sizeof(T_EEPROM_TYPE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int md_eeprom_read_byte(unsigned int address)
|
||||
{
|
||||
if (address == md_eeprom.type.sda_out_adr)
|
||||
{
|
||||
return eeprom_out();
|
||||
}
|
||||
|
||||
return READ_BYTE(cart.rom, address);
|
||||
}
|
||||
|
||||
unsigned int md_eeprom_read_word(unsigned int address)
|
||||
{
|
||||
if (address == md_eeprom.type.sda_out_adr)
|
||||
{
|
||||
return (eeprom_out() << 8);
|
||||
}
|
||||
|
||||
if (address == (md_eeprom.type.sda_out_adr ^ 1))
|
||||
{
|
||||
return eeprom_out();
|
||||
}
|
||||
|
||||
return *(uint16 *)(cart.rom + address);
|
||||
}
|
||||
|
||||
void md_eeprom_write_byte(unsigned int address, unsigned int data)
|
||||
{
|
||||
int do_update = 0;
|
||||
|
||||
if (address == md_eeprom.type.sda_in_adr)
|
||||
{
|
||||
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 >> 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);
|
||||
}
|
@ -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
|
@ -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<GAME_DATABASE_CNT; i++)
|
||||
{
|
||||
if (crc == game_list[i].crc)
|
||||
{
|
||||
cart.special = game_list[i].glasses_3d;
|
||||
/* auto-detect cartridge mapper */
|
||||
slot.mapper = game_list[i].mapper;
|
||||
|
||||
/* auto-detect required peripherals */
|
||||
device = game_list[i].peripheral;
|
||||
|
||||
/* auto-detect 3D glasses support */
|
||||
cart.special = game_list[i].g_3d;
|
||||
|
||||
/* auto-detect system hardware */
|
||||
if (!config.system || ((config.system == SYSTEM_GG) && (game_list[i].system == SYSTEM_GGMS)))
|
||||
{
|
||||
system_hw = game_list[i].system;
|
||||
}
|
||||
|
||||
/* auto-detect YM2413 chip support in AUTO mode */
|
||||
if (config.ym2413 & 2)
|
||||
{
|
||||
config.ym2413 |= game_list[i].fm;
|
||||
}
|
||||
|
||||
/* game found, leave loop */
|
||||
i = GAME_DATABASE_CNT;
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize Z80 write handler */
|
||||
/* initialize Z80 memory handlers */
|
||||
switch(slot.mapper)
|
||||
{
|
||||
case MAPPER_NONE:
|
||||
z80_readmem = read_mapper_default;
|
||||
z80_writemem = write_mapper_none;
|
||||
break;
|
||||
|
||||
case MAPPER_CODIES:
|
||||
z80_readmem = read_mapper_default;
|
||||
z80_writemem = write_mapper_codies;
|
||||
break;
|
||||
|
||||
case MAPPER_KOREA:
|
||||
z80_readmem = read_mapper_default;
|
||||
z80_writemem = write_mapper_korea;
|
||||
break;
|
||||
|
||||
case MAPPER_MSX:
|
||||
z80_readmem = read_mapper_default;
|
||||
z80_writemem = write_mapper_msx;
|
||||
break;
|
||||
|
||||
case MAPPER_93C46:
|
||||
gg_eeprom_init();
|
||||
z80_readmem = read_mapper_93c46;
|
||||
z80_writemem = write_mapper_93c46;
|
||||
break;
|
||||
|
||||
case MAPPER_TEREBI:
|
||||
cart.special |= HW_TEREBI_OEKAKI;
|
||||
z80_readmem = read_mapper_terebi;
|
||||
z80_writemem = write_mapper_terebi;
|
||||
break;
|
||||
|
||||
default:
|
||||
z80_readmem = read_mapper_default;
|
||||
z80_writemem = write_mapper_sega;
|
||||
break;
|
||||
}
|
||||
|
||||
/* initialize default SRAM (32K max.) */
|
||||
/* initialize SRAM */
|
||||
sram_init();
|
||||
|
||||
/* restore previous input settings */
|
||||
@ -226,23 +416,24 @@ void sms_cart_init(void)
|
||||
input.x_offset = 20;
|
||||
input.y_offset = 0;
|
||||
|
||||
/* detect if game requires specific peripheral */
|
||||
if (device != SYSTEM_MS_GAMEPAD)
|
||||
/* save current settings */
|
||||
if (old_system[0] == -1)
|
||||
{
|
||||
/* save port A setting */
|
||||
if (old_system[0] == -1)
|
||||
{
|
||||
old_system[0] = input.system[0];
|
||||
}
|
||||
old_system[0] = input.system[0];
|
||||
}
|
||||
if (old_system[1] == -1)
|
||||
{
|
||||
old_system[1] = input.system[1];
|
||||
}
|
||||
|
||||
/* force port A configuration */
|
||||
input.system[0] = device;
|
||||
/* force port A & port B configuration */
|
||||
input.system[0] = device;
|
||||
input.system[1] = SYSTEM_MS_GAMEPAD;
|
||||
|
||||
/* SpaceGun & Gangster Town use different gun offset */
|
||||
if ((crc == 0x5359762D) || (crc == 0x5FC74D2A))
|
||||
{
|
||||
input.x_offset = 16;
|
||||
}
|
||||
/* SpaceGun & Gangster Town use different gun offset */
|
||||
if ((crc == 0x5359762D) || (crc == 0x5FC74D2A))
|
||||
{
|
||||
input.x_offset = 16;
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,24 +444,52 @@ void sms_cart_reset(void)
|
||||
/* Unmapped memory return $FF */
|
||||
memset(dummy, 0xFF, 0x400);
|
||||
|
||||
/* Reset Z80 memory mapping at $0000-$BFFF (first 32k of ROM mirrored) */
|
||||
for(i = 0x00; i < 0x30; i++)
|
||||
/* $0000-$7FFF mapped to Cartridge ROM (32K) */
|
||||
for(i = 0x00; i < 0x20; i++)
|
||||
{
|
||||
z80_readmap[i] = &cart.rom[(i & 0x1F) << 10];
|
||||
z80_readmap[i] = &cart.rom[i << 10];
|
||||
z80_writemap[i] = dummy;
|
||||
}
|
||||
|
||||
/* Reset Z80 memory mapping at $C000-$FFFF (first 8K of 68k RAM mirrored) */
|
||||
for(i = 0x30; i < 0x40; i++)
|
||||
/* $8000-$BFFF mapped to Cartridge ROM or RAM (16K) */
|
||||
if (cart.romsize > 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];
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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();
|
||||
|
230
source/genesis.c
230
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();
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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());
|
||||
}
|
@ -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
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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 <iso9660.h>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
265
source/gx/fileio/fileio.c
Normal file
265
source/gx/fileio/fileio.c
Normal file
@ -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;
|
||||
}
|
48
source/gx/fileio/fileio.h
Normal file
48
source/gx/fileio/fileio.h
Normal file
@ -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_ */
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* 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--;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 <wiiuse/wpad.h>
|
||||
@ -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; i<maxfiles; i++)
|
||||
{
|
||||
if (filelist[i].flags && !strcmp(prev_folder,filelist[i].filename))
|
||||
if ((filelist[i].flags) && !strcmp(prev_folder,filelist[i].filename))
|
||||
{
|
||||
selection = i;
|
||||
offset = (i / 10) * 10;
|
||||
@ -498,9 +548,42 @@ int FileSelector(void)
|
||||
{
|
||||
string_offset = 0;
|
||||
|
||||
/* 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 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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 <ogc/lwp_threads.h>
|
||||
#include <ogc/lwp_watchdog.h>
|
||||
|
||||
#ifdef HW_RVL
|
||||
#include <ogc/usbmouse.h>
|
||||
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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_
|
||||
|
@ -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<<chan)))
|
||||
{
|
||||
/* restore inputs update callback */
|
||||
VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu);
|
||||
VIDEO_Flush();
|
||||
sprintf(msg, "PAD #%d is not connected !", chan+1);
|
||||
GUI_WaitPrompt("Error",msg);
|
||||
inputs_disabled = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Configure each keys */
|
||||
do
|
||||
{
|
||||
/* remove any pending keys */
|
||||
while (PAD_ButtonsHeld(chan))
|
||||
/* check for unused keys */
|
||||
if (strcmp(keyname[first_key], "N.A"))
|
||||
{
|
||||
VIDEO_WaitVSync();
|
||||
PAD_ScanPads();
|
||||
/* remove any pending keys */
|
||||
while (PAD_ButtonsHeld(chan))
|
||||
{
|
||||
VIDEO_WaitVSync();
|
||||
PAD_ScanPads();
|
||||
}
|
||||
|
||||
/* wait for user input */
|
||||
sprintf(msg,"Press key for %s\n(D-PAD to return)",keyname[first_key]);
|
||||
GUI_MsgBoxUpdate(0,msg);
|
||||
|
||||
key = 0;
|
||||
while (!key)
|
||||
{
|
||||
/* update PAD status */
|
||||
VIDEO_WaitVSync();
|
||||
PAD_ScanPads();
|
||||
p = PAD_ButtonsDown(chan);
|
||||
|
||||
/* find pressed key */
|
||||
if (p & PAD_BUTTON_A) key = PAD_BUTTON_A;
|
||||
else if (p & PAD_BUTTON_B) key = PAD_BUTTON_B;
|
||||
else if (p & PAD_BUTTON_X) key = PAD_BUTTON_X;
|
||||
else if (p & PAD_BUTTON_Y) key = PAD_BUTTON_Y;
|
||||
else if (p & PAD_TRIGGER_R) key = PAD_TRIGGER_R;
|
||||
else if (p & PAD_TRIGGER_L) key = PAD_TRIGGER_L;
|
||||
else if (p & PAD_TRIGGER_Z) key = PAD_TRIGGER_Z;
|
||||
else if (p & PAD_BUTTON_START) key = PAD_BUTTON_START;
|
||||
else if (p) key = 0xff;
|
||||
}
|
||||
|
||||
/* exit */
|
||||
if (key == 0xff) break;
|
||||
|
||||
/* update key mapping */
|
||||
config.pad_keymap[chan][first_key] = key;
|
||||
}
|
||||
|
||||
/* wait for user input */
|
||||
sprintf(msg,"Press key for %s\n(D-PAD to return)",keyname[first_key]);
|
||||
GUI_MsgBoxUpdate(0,msg);
|
||||
|
||||
key = 0;
|
||||
while (!key)
|
||||
{
|
||||
/* update PAD status */
|
||||
VIDEO_WaitVSync();
|
||||
PAD_ScanPads();
|
||||
p = PAD_ButtonsDown(chan);
|
||||
|
||||
/* find pressed key */
|
||||
if (p & PAD_BUTTON_A) key = PAD_BUTTON_A;
|
||||
else if (p & PAD_BUTTON_B) key = PAD_BUTTON_B;
|
||||
else if (p & PAD_BUTTON_X) key = PAD_BUTTON_X;
|
||||
else if (p & PAD_BUTTON_Y) key = PAD_BUTTON_Y;
|
||||
else if (p & PAD_TRIGGER_R) key = PAD_TRIGGER_R;
|
||||
else if (p & PAD_TRIGGER_L) key = PAD_TRIGGER_L;
|
||||
else if (p & PAD_TRIGGER_Z) key = PAD_TRIGGER_Z;
|
||||
else if (p & PAD_BUTTON_START) key = PAD_BUTTON_START;
|
||||
else if (p) key = 0xff;
|
||||
}
|
||||
|
||||
/* exit */
|
||||
if (key == 0xff) break;
|
||||
|
||||
/* update key mapping */
|
||||
config.pad_keymap[chan][first_key] = key;
|
||||
}
|
||||
while (first_key++ < last_key);
|
||||
|
||||
@ -144,9 +163,8 @@ static void pad_config(int chan, int first_key, int last_key)
|
||||
PAD_ScanPads();
|
||||
}
|
||||
|
||||
/* restore inputs update callback */
|
||||
VIDEO_SetPostRetraceCallback(gx_input_UpdateMenu);
|
||||
VIDEO_Flush();
|
||||
/* enable menu inputs update */
|
||||
inputs_disabled = 0;
|
||||
}
|
||||
|
||||
static void pad_update(s8 chan, u8 i)
|
||||
@ -305,7 +323,7 @@ static void pad_update(s8 chan, u8 i)
|
||||
break;
|
||||
}
|
||||
|
||||
case DEVICE_TABLET:
|
||||
case DEVICE_PICO:
|
||||
{
|
||||
/* D-PAD */
|
||||
if (p & PAD_BUTTON_UP) input.pad[i] |= INPUT_UP;
|
||||
@ -330,6 +348,24 @@ static void pad_update(s8 chan, u8 i)
|
||||
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;
|
||||
|
||||
/* 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();
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 <png.h>
|
||||
|
||||
@ -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<MAX_DEVICES; i++)
|
||||
{
|
||||
crosshair[0] = gxTextureOpenPNG(Crosshair_p1_png,0);
|
||||
}
|
||||
if (config.gun_cursor[1] && ((input.system[1] == SYSTEM_JUSTIFIER) || (input.system[1] == SYSTEM_LIGHTPHASER)))
|
||||
{
|
||||
crosshair[1] = gxTextureOpenPNG(Crosshair_p2_png,0);
|
||||
/* Check for emulated lightguns */
|
||||
if (input.dev[i] == DEVICE_LIGHTGUN)
|
||||
{
|
||||
/* Check if input device is affected to player */
|
||||
if (config.input[player].device >= 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)
|
||||
|
@ -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);
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 23 KiB |
313
source/gx/main.c
313
source/gx/main.c
@ -3,30 +3,44 @@
|
||||
*
|
||||
* Genesis Plus GX
|
||||
*
|
||||
* Softdev (2006)
|
||||
* Eke-Eke (2007-2010)
|
||||
* 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 "gui.h"
|
||||
#include "menu.h"
|
||||
#include "aram.h"
|
||||
#include "history.h"
|
||||
#include "file_slot.h"
|
||||
#include "file_load.h"
|
||||
@ -37,6 +51,7 @@
|
||||
|
||||
#ifdef HW_RVL
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#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;
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <sys/dir.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <asndlib.h>
|
||||
#include <oggplayer.h>
|
||||
|
||||
@ -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;
|
||||
|
@ -2,6 +2,9 @@
|
||||
Copyright (c) 2008 Francisco Muñoz 'Hermes' <www.elotrolado.net>
|
||||
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:
|
||||
|
||||
|
@ -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 <string.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
|
||||
|
40
source/hvc.h
40
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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
77
source/input_hw/terebi_oekaki.c
Normal file
77
source/input_hw/terebi_oekaki.c
Normal file
@ -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;
|
||||
}
|
47
source/input_hw/terebi_oekaki.h
Normal file
47
source/input_hw/terebi_oekaki.h
Normal file
@ -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
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************************/
|
||||
|
||||
|
256
source/io_ctrl.c
256
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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_ */
|
||||
|
||||
|
148
source/loadrom.c
148
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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
||||
/* ======================================================================== */
|
||||
|
@ -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 <stdlib.h>
|
||||
|
||||
// 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;
|
||||
}
|
@ -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 ============================= */
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
37084
source/m68k/m68kops.c
37084
source/m68k/m68kops.c
File diff suppressed because it is too large
Load Diff
25425
source/m68k/m68kops.h
25425
source/m68k/m68kops.h
File diff suppressed because it is too large
Load Diff
112
source/mem68k.c
112
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 */
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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_
|
||||
|
||||
|
501
source/memz80.c
501
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);
|
||||
}
|
||||
}
|
||||
|
@ -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_ */
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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_ */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user