updated SDL and DOS versions

This commit is contained in:
ekeeke31 2008-08-21 20:34:00 +00:00
parent 54fd830729
commit 6749058dad
44 changed files with 848 additions and 2732 deletions

View File

@ -1,22 +0,0 @@
[04/20/03]
- Modified 68000 emulator to prevent 'tas.b $mem' from writing data back
after a read (fixes Gargoyles).
- Fixed bug in 68000 emulator to swap order of words written for address
register indirect pre-decremented writes (fixes Jim Power graphics).
- Added support for 240-line displays (for Super Skidmarks).
- Rewrote part of the interrupt handling (fixes some raster effects).
- Removed sprite collision detection code (never really worked).
- Optimized sprite rendering inner loop.
[04/13/03]
- Finished up memory map for VDP DMA V-bus reads.
- Fixed handling of 68000 writes to I/O chip at even addresses.
- Fixed bit 7 handling of control register in I/O chip.
- Finished up Z80 memory map.
- Added code to handle Genesis hardware lock-ups.
- Removed some faulty code from the 68000 memory map handlers.
[03/22/03]
- Completed implementation of Z80 banked memory handlers.

View File

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

View File

@ -1,89 +0,0 @@
Introduction
Genesis Plus has reasonable speed, and very fast rendering. Here are some
details about porting it to another platform
Porting rules
- This program is released under the GPL, so please release the source
code for your derivative ports. Let me know if you need an alternative
to this.
- Do not change the name of the emulator. Something like 'Genesis Plus / MacOS'
is fine as it keeps the original name.
- Configure the CPU emulators for little or big-endian CPUs, and use the
ALIGN_LONG option to handle unaligned memory accesses if needed. E.g. if
the emulator crashes when a game scrolls horizontally, you need to enable
it.
Requirements
- At this time the 16-bit rendering code has been well tested and should
be used. There is code to support 8 through 32-bit displays, but I
haven't checked if it still works.
- Audio output, if enabled, uses stereo 16-bit samples.
Functions to use:
int load_rom(char *filename);
Loads a game which can be in BIN, SMD or ZIP formats. It returns zero if
an error has occured.
void system_init(void);
Initializes the virtual Genesis console. Call this once during startup.
void audio_init(int rate);
Initialize the sound emulation part of the emulator. Pass zero or don't
call the function to disable sound. Call this after running system_init().
void system_reset(void);
Resets the virtual Genesis console. Call this once during setup, and later
as needed.
int system_frame(int skip);
Updates the emulation for a frame. Pass 1 to prevent rendering (which can
be used for frame skipping) and 0 to render the current display.
This function returns 0 if the virtual Genesis console has locked up.
You can do what you'd like with this information, such as notify the user,
reset the machine, etc.
If audio is enabled, the snd.buffer[] array will hold the current audio
data for this frame.
void system_shutdown(void);
Shuts down the emulator.
Variables:
The 'bitmap' structure needs to be filled out prior to calling system_init().
This provides the rendering code with information about the type of bitmap
it is rendering to. I would advise sticking with a 1024x512 16-bit bitmap:
memset(&bitmap, 0, sizeof(t_bitmap));
bitmap.width = 1024;
bitmap.height = 512;
bitmap.depth = 16;
bitmap.granularity = 2; /* Bytes per pixel */
bitmap.pitch = (bitmap.width * bitmap.granularity);
bitmap.data = (unsigned char *)bmp->pixels; /* Pointer to your bitmap */
bitmap.viewport.w = 256; /* Initial size of display on power-up (do not change) */
bitmap.viewport.h = 224;
bitmap.viewport.x = 0x20; /* Offset used for rendering (do not change) */
bitmap.viewport.y = 0x00;
bitmap.remap = 1;
The variable 'input.pad[0]' holds the button states for the first player
gamepad. Update this prior to calling system_frame(), and use the bitmasks
defined in system.h such as 'INPUT_UP', etc.
See the Windows/SDL and DOS drivers for examples.

View File

@ -1,122 +0,0 @@
----------------------------------------------------------------------------
Genesis Plus
----------------------------------------------------------------------------
Version 1.2a
by Charles Mac Donald
WWW: http://cgfm2.emuviews.com
What's New
----------
[06/22/03]
- Modified rendering code for portability
- Modified memory handling to fix banked PSG access
[05/13/03]
- Initial release
Usage
-----
The Windows version runs windowed in a 16-bit desktop with NO sound or
joystick support.
The DOS version has most of the functionality from SMS Plus, such
as audio, joysticks, etc.
Windows/DOS controls:
Arrow Keys - Directional pad
A,S,D,F - 1P gamepad, buttons A, B, C, Start
Tab - Reset
Esc - Exit program
DOS only:
End - Exit program
F1-F4 - Set frameskip level (F1 = no skip ... F4 = skip 3 frames)
F8 - Make PCX screen snapshot
F9 - Toggle VSync
F10 - Toggle speed throttling
F11 - Toggle FPS meter
DOS details:
You can only support a second player if you are using a joystick driver
that supports more than one joystick. (e.g. Sidewinder, dual pads, etc.)
Type 'gen -help' on the command line for a list of useful options.
-res <x> <y> set the display resolution.
-vdriver <n> specify video driver.
-depth <n> specify color depth. (8, 16)
-scanlines use scanlines effect.
-scale scale display to full resolution. (slow)
-vsync wait for vertical sync before blitting.
-sound enable sound. (force speed throttling)
-sndrate <n> specify sound rate. (8000, 11025, 22050, 44100)
-sndcard <n> specify sound card. (0-7)
-swap swap left and right stereo output.
-joy <s> specify joystick type.
Here is a list of all the video drivers you can pass as a parameter
to the '-vdriver' option:
auto, safe, vga, modex, vesa2l, vesa3, vbeaf
Here is a list of all the joystick drivers you can pass as a parameter
to the '-joy' option:
auto, none, standard, 2pads, 4button, 6button, 8button, fspro, wingex,
sidewinder, gamepadpro, grip, grip4, sneslpt1, sneslpt2, sneslpt3,
psxlpt1, psxlpt2, psxlpt3, n64lpt1, n64lpt2, n64lpt3, db9lpt1, db9lpt2,
db9lpt3, tglpt1, tglpt2, tglpt3, wingwar, segaisa, segapci, segapci2
You can put any commandline option into a plain text file which should
be called "gen.cfg". Put one option per line, please. Command line options
will override anything in the configuration file.
Currently the zip loading code can manage a zipfile where the game
image is the first thing in it. If you try to open a huge archive of
games, only the first will be played.
Credits and Acknowlegements
---------------------------
I would like to thank Omar Cornut, Christian Schiller, and Chris MacDonald
for their invaluable help and support with this project.
Richard Bannister for the Macintosh port and all of the code fixes and
suggestions that have made Genesis Plus a better program.
(http://www.bannister.org)
The Genesis emulator authors: Bart Trzynadlowski, Quintesson, Steve Snake,
James Ponder, Stef, Gerrie, Sardu.
The regular people and many lurkers at segadev.
The MAME team for the CPU and sound chip emulators.
Everyone who has contributed, donated, and submitted information to help
out Genesis Plus and my efforts documenting the Genesis hardware.
Contact
-------
Charles MacDonald
E-mail: cgfm2@hotmail.com
WWW: http://cgfm2.emuviews.com
Legal
-----
Copyright (C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald
The source code is distributed under the terms of the GNU General Public
License.
The Z80 CPU emulator, 68K CPU emulator, and the PSG, YM2612 emulation code
are taken from the MAME project, and terms of their use are covered under
the MAME license.
(http://www.mame.net)

View File

@ -1,79 +0,0 @@
Here are some technical details about things that need to be fixed or
added to Genesis Plus.
Missing features:
- Support for 6-button controllers
- SRAM management
- Game Genie / PAR patch codes
The VDP code could use a lot of cleaning up.
The rendering code is missing a few bits:
- Sprite collision
- Window bug
I think the "C" 68000 emulator either has some bugs or I'm not using it
correctly. Older DOS-only versions used Turbo68K, which had ran games
much better, especially with regards to interrupt handling.
Things that need to be fixed:
- Raster garbage on third road in Thunder Blade.
- Added country codes for Dragon Slayer, but game locks up after
passing country check.
- No inputs in Samurai Shodown.
(This game doesn't initialize the port direction registers, at least not
directly. Emulation bug or problem with the game?)
- Palette and raster problems in Mortal Kombat.
- Bad raster effects and VRAM corruption in Super Skidmarks.
(Needs PAL timing)
- Palette problems in Sonic 2 title screen.
- Masked half of Sonic sprite visible on Sonic title screen.
- Sprite masking doesn't work in Micro Machines subscreen.
- Music has slow tempo in Batman & Robin. (doesn't seem to be a problem
with the YM2612 timers - Wonderboy 3 is normal)
- Music has jerky playback in Sonic 2, 3, 3D Blast. If you run the Z80
emulation for one scanline after requesting an interrupt, it runs fine.
- DAC and PSG output are too loud, both are divided by two for now
(though the PSG should be a bit quieter and the DAC a bit louder)
- Undead Line locks after selecting a stage, also the Z80 sound halts
after the first note is played.
This game single steps the Z80 with the following code:
MOVEM.L D0,-(A7) ; 009C7C 48 E7 80 00
ORI #$0200,SR ; 009C80 00 7C 02 00
; Get control of the Z-bus
MOVE.W #$0100,$00A11100 ; 009C84 33 FC 01 00 00 A1 11 00
BTST #$00,$00A11100 ; 009C8C 08 39 00 00 00 A1 11 00
BNE.S *-$08 [00009C8C] ; 009C94 66 F6
; Check driver status byte. If zero, release bus and exit.
TST.B $00A00008 ; 009C96 4A 39 00 A0 00 08
BEQ *+$0016 [00009CB2] ; 009C9C 67 00 00 14
; Release bus and wait for Z80 to resume control. Then restart the loop
; and immediately get the bus back again, assuming the Z80 ran at least
; one instruction in the meantime.
CLR.W $00A11100 ; 009CA0 42 79 00 A1 11 00
BTST #$00,$00A11100 ; 009CA6 08 39 00 00 00 A1 11 00
BEQ.S *-$08 [00009CA6] ; 009CAE 67 F6
BRA.S *-$2C [00009C84] ; 009CB0 60 D2
; Release bus and exit.
CLR.W $00A11100 ; 009CB2 42 79 00 A1 11 00
ANDI #$FDFF,SR ; 009CB8 02 7C FD FF
MOVEM.L (A7)+,D0 ; 009CBC 4C DF 00 01
RTS ; 009CC0 4E 75

View File

@ -21,8 +21,8 @@
*
****************************************************************************************/
#ifndef _INPUT_HW_H_
#define _INPUT_HW_H_
#ifndef _GEN_INPUT_H_
#define _GEN_INPUT_H_
/* Max. number of devices */
#define MAX_DEVICES (8)

View File

@ -21,8 +21,8 @@
*
****************************************************************************************/
#ifndef _IO_H_
#define _IO_H_
#ifndef _GEN_IO_H_
#define _GEN_IO_H_
#define REGION_USA 0x80
#define REGION_JAPAN_NTSC 0x00

View File

@ -12,6 +12,7 @@ typedef struct
double psg_preamp;
double fm_preamp;
uint8 boost;
uint8 filter;
uint8 hq_fm;
uint8 fm_core;
int8 sram_auto;

View File

@ -17,8 +17,8 @@
#include "memz80.h"
#include "membnk.h"
#include "memvdp.h"
#include "io.h"
#include "input.h"
#include "gen_io.h"
#include "gen_input.h"
#include "state.h"
#include "sound.h"
#include "sn76489.h"

View File

@ -49,7 +49,11 @@
#undef HAVE_LIBM
/* Define if you have C99's lrint function. */
#ifdef DOS
#define HAVE_LRINT 0
#else
#define HAVE_LRINT 1
#endif
/* Define if you have C99's lrintf function. */
#define HAVE_LRINTF 1

View File

@ -787,11 +787,28 @@ INLINE void set_tl(FM_CH *CH,FM_SLOT *SLOT , int v)
/* set attack rate & key scale */
INLINE void set_ar_ksr(FM_CH *CH,FM_SLOT *SLOT,int v)
{
SLOT->ar = (v&0x1f) ? (32 + ((v&0x1f)<<1)) : 0;
UINT8 old_KSR = SLOT->KSR;
SLOT->ar = (v&0x1f) ? 32 + ((v&0x1f)<<1) : 0;
SLOT->KSR = 3-(v>>6);
CH->SLOT[SLOT1].Incr=-1;
}
if (SLOT->KSR != old_KSR)
{
CH->SLOT[SLOT1].Incr=-1;
}
/* refresh Attack rate */
if ((SLOT->ar + SLOT->ksr) < 94 /*32+62*/)
{
SLOT->eg_sh_ar = eg_rate_shift [SLOT->ar + SLOT->ksr ];
SLOT->eg_sel_ar = eg_rate_select[SLOT->ar + SLOT->ksr ];
}
else
{
SLOT->eg_sh_ar = 0;
SLOT->eg_sel_ar = 17*RATE_STEPS;
}
}
/* set decay rate */
INLINE void set_dr(FM_SLOT *SLOT,int v)

View File

@ -2373,11 +2373,8 @@ void YM2612_Update(int **buf, int length)
{
for(i = 0; i < length; i++)
{
long dac = (YM2612.DACdata << 15) - dac_highpass;
dac_highpass += dac >> 9;
dac >>= 15;
buf[0][i] += dac & YM2612.CHANNEL[5].LEFT;
buf[1][i] += dac & YM2612.CHANNEL[5].RIGHT;
buf[0][i] += YM2612.DACdata & YM2612.CHANNEL[5].LEFT;
buf[1][i] += YM2612.DACdata & YM2612.CHANNEL[5].RIGHT;
}
}

View File

@ -337,7 +337,8 @@ static void audio_update (void)
int l, r;
double psg_preamp = config.psg_preamp;
double fm_preamp = config.fm_preamp;
uint8 boost = config.boost;
int boost = config.boost;
int filter = config.filter;
#ifdef NGC
int16 *sb = (int16 *) soundbuffer[mixbuffer];
@ -357,8 +358,13 @@ static void audio_update (void)
snd.psg.buffer[i] = 0;
/* single-pole low-pass filter (6 dB/octave) */
ll = (ll + l) >> 1;
rr = (rr + r) >> 1;
if (filter)
{
l = (ll + l) >> 1;
r = (rr + r) >> 1;
ll = l;
rr = r;
}
/* boost volume if asked*/
l = ll * boost;
@ -374,7 +380,7 @@ static void audio_update (void)
#ifdef NGC
*sb++ = r; // RIGHT channel comes first
*sb++ = l;
#else
#elif DOS
snd.buffer[0][i] = l;
snd.buffer[1][i] = r;
#endif

View File

@ -16,9 +16,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _TYPES_H_
#define _TYPES_H_
#undef uint8
#undef uint16
#undef uint32
@ -30,4 +27,3 @@
#define int16 signed short
#define int32 signed long int
#endif /* _TYPES_H_ */

View File

@ -1,28 +1,36 @@
# MekaDrive - Sega Mega Drive emulator
# Makefile for genplus DOS
#
# (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald
# modified by Eke-Eke <eke_eke31@yahoo.fr>
#
# Defines :
# -DLSB_FIRST - Leave undefined for big-endian processors.
# -DDOS - Enable DOS/x86 specific code.
# -DDEBUG - Enable debugging code
# -DX86_ASM - Enable inline x86 assembly code in Z80 emulator
CC = gcc
CC = gcc
AS = nasm -f coff
LDFLAGS =
FLAGS = -I. -Icpu -Im68k -Idos -Isound -Icart_hw -Icart_hw\svp \
-Werror -Wall \
-O6 -mcpu=pentium -fomit-frame-pointer \
FLAGS = -I. -I.. -I../cpu -I../m68k -I../dos -I../sound -I../sound/SRC -I../cart_hw -I../cart_hw/svp \
-Wall -g \
-O6 -march=i686 -fomit-frame-pointer \
-DLSB_FIRST -DX86_ASM -DDOS
LIBS = -lalleg -laudio -lz obj/m68k.oa
LIBS = -lalleg -laudio -lz -lm
OBJ = obj/z80.oa \
obj/genesis.o \
OBJ = obj/z80.o
OBJ += obj/m68kcpu.o \
obj/m68kops.o
OBJ += obj/genesis.o \
obj/vdp.o \
obj/render.o \
obj/system.o \
obj/io.o \
obj/input.o \
obj/gen_io.o \
obj/gen_input.o \
obj/mem68k.o \
obj/memz80.o \
obj/membnk.o \
@ -34,6 +42,12 @@ OBJ += obj/sound.o \
obj/sn76489.o \
obj/ym2612.o
OBJ += obj/samplerate.o \
obj/src_linear.o \
obj/src_sinc.o \
obj/src_zoh.o \
OBJ += obj/sram.o \
obj/eeprom.o \
obj/svp.o \
@ -54,34 +68,39 @@ all : $(EXE)
$(EXE) : $(OBJ)
$(CC) -o $(EXE) $(OBJ) $(LIBS) $(LDFLAGS)
obj/%.oa : cpu/%.c cpu/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : %.c %.h
obj/%.o : ../%.c ../%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : asm/%.s
obj/%.o : ../asm/%.s
$(AS) $< -o $@
obj/%.o : sound/%.c sound/%.h
obj/%.o : ../sound/%.c ../sound/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : sound/%.c
obj/%.o : ../sound/%.c
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : cart_hw/%.c cart_hw/%.h
obj/%.o : ../sound/SRC/%.c ../sound/SRC/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : ../sound/SRC/%.c
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : cart_hw/svp/%.c
obj/%.o : ../cart_hw/%.c ../cart_hw/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : cart_hw/svp/%.c cart_hw/svp/%.h
obj/%.o : ../cart_hw/svp/%.c
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : cpu/%.c cpu/%.h
obj/%.o : ../cart_hw/svp/%.c ../cart_hw/svp/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : dos/%.c dos/%.h
obj/%.o : ../cpu/%.c ../cpu/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : ../m68k/%.c ../m68k/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : ./%.c ./%.h
$(CC) -c $< -o $@ $(FLAGS)
pack :

View File

@ -1,6 +1,8 @@
#include "osd.h"
#define CONFIG_VERSION "GENPLUS 1.2.1 "
t_option option;
t_config config;
@ -70,9 +72,9 @@ int check_bool(char *token)
void set_option_defaults(void)
{
option.video_driver = GFX_AUTODETECT;
option.video_width = 320;
option.video_height = 240;
option.video_depth = 8;
option.video_width = 640;
option.video_height = 480;
option.video_depth = 16;
option.remap = 1;
option.scanlines = 0;
@ -90,13 +92,16 @@ void set_option_defaults(void)
option.joy_driver = JOY_TYPE_NONE;
}
/* additional options */
void set_config_default()
void set_config_defaults(void)
{
/* version TAG */
strncpy(config.version,CONFIG_VERSION,15);
/* sound options */
config.psg_preamp = 1.5;
config.fm_preamp = 1.0;
config.boost = 1;
config.filter = 0;
config.hq_fm = 1;
config.fm_core = 0;
@ -110,16 +115,15 @@ void set_config_default()
/* display options */
config.xshift = 0;
config.yshift = 0;
config.xscale = 320;
config.yscale = 240;
config.xscale = 0;
config.yscale = 0;
config.aspect = 1;
config.overscan = 1;
config.render = 0;
/* controllers options */
config.sys_type[0] = 0;
config.sys_type[1] = 0;
config.crosshair = 1;
config.gun_cursor = 1;
config.invert_mouse = 0;
}
void print_options(void)
@ -232,7 +236,7 @@ void parse_args(int argc, char **argv)
}
}
//if(option.remap) option.video_depth = 8;
if(option.remap) option.video_depth = 8;
}

View File

@ -48,12 +48,17 @@ typedef struct
int softres; /* 1= Allow RUN+SELECT */
} t_option;
/****************************************************************************
* Config Option
*
****************************************************************************/
typedef struct
{
char[10] version;
char version[15];
double psg_preamp;
double fm_preamp;
uint8 boost;
uint8 boost;
uint8 filter;
uint8 hq_fm;
uint8 fm_core;
int8 sram_auto;
@ -69,8 +74,8 @@ typedef struct
uint8 aspect;
uint8 overscan;
uint8 render;
uint8 sys_type[2];
uint8 crosshair;
uint8 gun_cursor;
uint8 invert_mouse;
} t_config;
/* Global variables */
@ -86,7 +91,7 @@ void parse_args(int argc, char **argv);
void print_options(void);
int check_bool(char *token);
void set_option_defaults(void);
void set_config_default(void);
void set_config_defaults(void);
#endif /* _CONFIG_H_ */

View File

@ -14,7 +14,7 @@ PALETTE gen_pal;
BITMAP *gen_bmp;
volatile int frame_skip = 1;
int frame_count = 0;
volatile int frame_count = 0;
volatile int frames_rendered = 0;
volatile int frame_rate = 0;
volatile int tick_count = 0;
@ -22,7 +22,7 @@ volatile int old_tick_count = 0;
volatile int skip = 0;
int quit = 0;
unsigned char buf[0x26000];
unsigned char buf[0x24000];
uint8 log_error = 1;
uint8 debug_on = 0;
@ -50,35 +50,42 @@ void msg_print(int x, int y, char *fmt, ...)
int main (int argc, char *argv[])
{
if(argc < 2) {
printf("Genesis Plus - Sega Mega Drive emulator (v1.0)\n");
printf("(C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald\n");
printf("Usage %s file.[bin|smd|zip] [-options]\n", argv[0]);
printf("Type `%s -help' for a list of options.\n", argv[0]);
exit(1);
};
if(argc < 2)
{
printf("Genesis Plus - Sega Mega Drive emulator (v1.0)\n");
printf("(C) 1999, 2000, 2001, 2002, 2003 Charles MacDonald\n");
printf("Usage %s file.[bin|smd|zip] [-options]\n", argv[0]);
printf("Type `%s -help' for a list of options.\n", argv[0]);
exit(1);
};
if(stricmp(argv[1], "-help") == 0)
{
print_options();
return (0);
}
error_init();
if(stricmp(argv[1], "-help") == 0)
{
print_options();
return (0);
}
error_init();
cart_rom = malloc(0xA00000);
memset(cart_rom, 0, 0xA00000);
cart_rom = malloc(0xA00000);
memset(cart_rom, 0, 0xA00000);
set_config_default();
if(!load_rom(argv[1]))
{
printf("File `%s' not found.\n", argv[1]);
return (0);
}
if(!load_rom(argv[1]))
{
printf("File `%s' not found.\n", argv[1]);
return (0);
}
/* load SRAM */
FILE *f = fopen("./game.srm", "rb");
if (f!=NULL)
{
fread(&sram.sram,0x10000,1, f);
fclose(f);
}
memset(bios_rom, 0, sizeof(bios_rom));
FILE *f = fopen("./BIOS.bin", "rb");
/* load BIOS */
memset(bios_rom, 0, sizeof(bios_rom));
f = fopen("./BIOS.bin", "rb");
if (f!=NULL)
{
fread(&bios_rom, 0x800,1,f);
@ -91,65 +98,58 @@ int main (int argc, char *argv[])
bios_rom[i+1] = temp;
}
config.bios_enabled = 3;
}
}
else config.bios_enabled = 0;
init_machine();
set_config_default();
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_GAMEPAD;
system_init();
/* initialize genesis VM */
init_machine();
/* default config */
set_config_defaults();
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_GAMEPAD;
/* initialize emulation */
int buf_len = (option.sndrate * 4) / vdp_rate;
snd.buffer[0] = malloc (buf_len/2);
snd.buffer[1] = malloc (buf_len/2);
memset (snd.buffer[0], 0, buf_len/2);
memset (snd.buffer[1], 0, buf_len/2);
system_init();
audio_init(option.sndrate);
f = fopen("./game.srm", "rb");
if (f!=NULL)
{
fread(&sram.sram,0x10000,1, f);
fclose(f);
}
system_reset();
for(;;)
/* emulation loop */
for(;;)
{
frame_count += 1;
if(quit) break;
if(frame_count % frame_skip == 0)
{
frame_count += 1;
if(quit) break;
if(frame_count % frame_skip == 0)
{
system_frame(0);
frames_rendered++;
system_frame(0);
frames_rendered++;
dos_update_video();
}
else
{
system_frame(1);
}
if(option.sound) dos_update_audio();
}
else
{
system_frame(1);
}
if(option.sound) dos_update_audio();
//error("%d\n", frame_rate);
}
f = fopen("./game.srm", "wb");
if (f!=NULL)
{
fwrite(&sram.sram, 0x10000,1,f);
fclose(f);
}
if (f!=NULL)
{
fwrite(&sram.sram, 0x10000,1,f);
fclose(f);
}
trash_machine();
system_shutdown();
error_shutdown();
return (0);
system_shutdown();
error_shutdown();
return (0);
}
/* Timer handler */
@ -185,127 +185,176 @@ int save_file(char *filename, char *buf, int size)
static int joynum = 0;
uint8 delay = 36;
int gun_offset = 0;
int old_mouse_x = 0;
int old_mouse_y = 0;
void dos_update_input(void)
{
FILE *f;
FILE *f;
if(key[KEY_ESC] || key[KEY_END])
{
quit = 1;
}
{
quit = 1;
}
while (input.dev[joynum] == NO_DEVICE)
{
joynum ++;
if (joynum > MAX_DEVICES - 1) joynum = 0;
joynum ++;
if (joynum > MAX_DEVICES - 1) joynum = 0;
}
if(check_key(KEY_F12))
{
input.x_offset ++;
if (input.x_offset > 0xff) input.x_offset = 0;
}
if(check_key(KEY_F11))
{
joynum ++;
if (joynum > MAX_DEVICES - 1) joynum = 0;
while (input.dev[joynum] == NO_DEVICE)
{
joynum ++;
if (joynum > MAX_DEVICES - 1) joynum = 0;
}
}
input.pad[joynum] = 0;
/* Is the joystick being used ? */
if(option.joy_driver != JOY_TYPE_NONE)
{
poll_joystick();
/* Check player 1 joystick */
if(joy[0].stick[0].axis[1].d1) input.pad[0] |= INPUT_UP;
else
if(joy[0].stick[0].axis[1].d2) input.pad[0] |= INPUT_DOWN;
if(joy[0].stick[0].axis[0].d1) input.pad[0] |= INPUT_LEFT;
else
if(joy[0].stick[0].axis[0].d2) input.pad[0] |= INPUT_RIGHT;
if(joy[0].button[0].b) input.pad[0] |= INPUT_A;
if(joy[0].button[1].b) input.pad[0] |= INPUT_B;
if(joy[0].button[2].b) input.pad[0] |= INPUT_C;
if(joy[0].button[3].b) input.pad[0] |= INPUT_START;
if(joy[0].button[4].b) input.pad[0] |= INPUT_X;
if(joy[0].button[5].b) input.pad[0] |= INPUT_Y;
if(joy[0].button[6].b) input.pad[0] |= INPUT_Z;
if(joy[0].button[7].b) input.pad[0] |= INPUT_MODE;
/* More than one joystick supported ? */
if(num_joysticks > 2)
/* Is the joystick being used ? */
if(option.joy_driver != JOY_TYPE_NONE)
{
/* Check player 2 joystick */
if(joy[1].stick[0].axis[1].d1) input.pad[1] |= INPUT_UP;
else
if(joy[1].stick[0].axis[1].d2) input.pad[1] |= INPUT_DOWN;
poll_joystick();
if(joy[1].stick[0].axis[0].d1) input.pad[1] |= INPUT_LEFT;
else
if(joy[1].stick[0].axis[0].d1) input.pad[1] |= INPUT_RIGHT;
/* Check player 1 joystick */
if(joy[0].stick[0].axis[1].d1) input.pad[0] |= INPUT_UP;
else
if(joy[0].stick[0].axis[1].d2) input.pad[0] |= INPUT_DOWN;
if(joy[1].button[0].b) input.pad[1] |= INPUT_A;
if(joy[1].button[1].b) input.pad[1] |= INPUT_B;
if(joy[1].button[2].b) input.pad[1] |= INPUT_C;
if(joy[1].button[3].b) input.pad[1] |= INPUT_START;
if(joy[1].button[4].b) input.pad[1] |= INPUT_X;
if(joy[1].button[5].b) input.pad[1] |= INPUT_Y;
if(joy[1].button[6].b) input.pad[1] |= INPUT_Z;
if(joy[1].button[7].b) input.pad[1] |= INPUT_MODE;
if(joy[0].stick[0].axis[0].d1) input.pad[0] |= INPUT_LEFT;
else
if(joy[0].stick[0].axis[0].d2) input.pad[0] |= INPUT_RIGHT;
if(joy[0].button[0].b) input.pad[0] |= INPUT_A;
if(joy[0].button[1].b) input.pad[0] |= INPUT_B;
if(joy[0].button[2].b) input.pad[0] |= INPUT_C;
if(joy[0].button[3].b) input.pad[0] |= INPUT_START;
if(joy[0].button[4].b) input.pad[0] |= INPUT_X;
if(joy[0].button[5].b) input.pad[0] |= INPUT_Y;
if(joy[0].button[6].b) input.pad[0] |= INPUT_Z;
if(joy[0].button[7].b) input.pad[0] |= INPUT_MODE;
/* More than one joystick supported ? */
if(num_joysticks > 2)
{
/* Check player 2 joystick */
if(joy[1].stick[0].axis[1].d1) input.pad[1] |= INPUT_UP;
else
if(joy[1].stick[0].axis[1].d2) input.pad[1] |= INPUT_DOWN;
if(joy[1].stick[0].axis[0].d1) input.pad[1] |= INPUT_LEFT;
else
if(joy[1].stick[0].axis[0].d1) input.pad[1] |= INPUT_RIGHT;
if(joy[1].button[0].b) input.pad[1] |= INPUT_A;
if(joy[1].button[1].b) input.pad[1] |= INPUT_B;
if(joy[1].button[2].b) input.pad[1] |= INPUT_C;
if(joy[1].button[3].b) input.pad[1] |= INPUT_START;
if(joy[1].button[4].b) input.pad[1] |= INPUT_X;
if(joy[1].button[5].b) input.pad[1] |= INPUT_Y;
if(joy[1].button[6].b) input.pad[1] |= INPUT_Z;
if(joy[1].button[7].b) input.pad[1] |= INPUT_MODE;
}
}
}
/* keyboard */
if(key[KEY_UP]) input.pad[joynum] |= INPUT_UP;
else
if(key[KEY_DOWN]) input.pad[joynum] |= INPUT_DOWN;
if(key[KEY_LEFT]) input.pad[joynum] |= INPUT_LEFT;
else
if(key[KEY_RIGHT]) input.pad[joynum] |= INPUT_RIGHT;
if(key[KEY_A]) input.pad[joynum] |= INPUT_A;
if(key[KEY_S]) input.pad[joynum] |= INPUT_B;
if(key[KEY_D]) input.pad[joynum] |= INPUT_C;
if(key[KEY_Z]) input.pad[joynum] |= INPUT_X;
if(key[KEY_Z]) input.pad[joynum] |= INPUT_X;
if(key[KEY_X]) input.pad[joynum] |= INPUT_Y;
if(key[KEY_C]) input.pad[joynum] |= INPUT_Z;
if(key[KEY_V]) input.pad[joynum] |= INPUT_MODE;
if(key[KEY_F])
{
if(key[KEY_UP]) input.pad[joynum] |= INPUT_UP;
else
if(key[KEY_DOWN]) input.pad[joynum] |= INPUT_DOWN;
if(key[KEY_LEFT]) input.pad[joynum] |= INPUT_LEFT;
else
if(key[KEY_RIGHT]) input.pad[joynum] |= INPUT_RIGHT;
if(check_key(KEY_A)) error("ButtonA pressed\n");
if(key[KEY_A]) {
input.pad[joynum] |= INPUT_A;
}
if(key[KEY_S]) input.pad[joynum] |= INPUT_B;
if(key[KEY_D]) input.pad[joynum] |= INPUT_C;
if(check_key(KEY_F)) error("start pressed\n");
if(key[KEY_F]) {
input.pad[joynum] |= INPUT_START;
error("start pressed\n");
}
}
extern uint8 pico_current;
if (input.dev[joynum] == DEVICE_LIGHTGUN)
{
/* Poll mouse if necessary */
if(mouse_needs_poll() == TRUE)
poll_mouse();
/* Calculate X Y axis values */
input.analog[joynum - 4][0] = (mouse_x * bitmap.viewport.w) / SCREEN_W;
input.analog[joynum - 4][1] = (mouse_y * bitmap.viewport.h) / SCREEN_H;
/* Calculate X axis value */
input.analog[joynum-4][0] = (mouse_x * bitmap.viewport.w)/SCREEN_W;;
/* Calculate Y axis value */
input.analog[joynum-4][1] = (mouse_y * bitmap.viewport.h)/SCREEN_H;;
/* Map mouse buttons to player #1 inputs */
if(mouse_b & 4) input.pad[joynum] |= INPUT_B;
if(mouse_b & 2) input.pad[joynum] |= INPUT_C;
if(mouse_b & 4) input.pad[joynum] |= INPUT_C;
if(mouse_b & 2) input.pad[joynum] |= INPUT_B;
if(mouse_b & 1) input.pad[joynum] |= INPUT_A;
if(key[KEY_F]) input.pad[joynum] |= INPUT_START;
}
else if (input.dev[joynum] == DEVICE_MOUSE)
{
/* Poll mouse if necessary */
if(mouse_needs_poll() == TRUE)
poll_mouse();
get_mouse_mickeys(&input.analog[2][0], &input.analog[2][1]);
input.analog[2][0] = (input.analog[2][0] * 256) / SCREEN_W;
input.analog[2][1] = (input.analog[2][1] * 256) / SCREEN_H;
if (config.invert_mouse) input.analog[2][1] = 0 - input.analog[2][1];
/* Map mouse buttons to player #1 inputs */
if(mouse_b & 4) input.pad[joynum] |= INPUT_C;
if(mouse_b & 1) input.pad[joynum] |= INPUT_B;
if(mouse_b & 2) input.pad[joynum] |= INPUT_A;
if(key[KEY_F]) input.pad[joynum] |= INPUT_START;
}
else if (system_hw == SYSTEM_PICO)
{
/* Poll mouse if necessary */
if(mouse_needs_poll() == TRUE)
poll_mouse();
/* Poll mouse if necessary */
if(mouse_needs_poll() == TRUE)
poll_mouse();
/* Calculate X Y axis values */
input.analog[0][0] = 0x3c + (mouse_x * (0x17c-0x03c+1)) / SCREEN_W;
input.analog[0][1] = 0x1fc + (mouse_y * (0x2f7-0x1fc+1)) / SCREEN_H;
/* Calculate X axis value */
input.analog[0][0] = 0x3c + (mouse_x * (0x17c - 0x3c + 1) / SCREEN_W);
/* Map mouse buttons to player #1 inputs */
if(mouse_b & 4) input.pad[joynum] |= INPUT_START;
if(mouse_b & 2) input.pad[joynum] |= INPUT_A;
if(mouse_b & 1) input.pad[joynum] |= INPUT_B;
/* Calculate Y axis value */
input.analog[0][1] = 0x1fc + (mouse_y* (0x3f3 - 0x1fc + 1) / SCREEN_H);
/* Map mouse buttons to player #1 inputs */
if(mouse_b & 2) input.pad[0] |= INPUT_B;
if(mouse_b & 1) input.pad[0] |= INPUT_A;
if(mouse_b & 4) pico_current++;
if (pico_current > 6) pico_current = 0;
}
if(check_key(KEY_F1)) frame_skip = 1;
if(check_key(KEY_F2)) frame_skip = 2;
if(check_key(KEY_F3)) frame_skip = 3;
if(check_key(KEY_F4)) frame_skip = 4;
if(check_key(KEY_F1)) frame_skip = 1;
if(check_key(KEY_F2)) frame_skip = 2;
if(check_key(KEY_F3)) frame_skip = 3;
if(check_key(KEY_F4)) frame_skip = 4;
if(check_key(KEY_F5)) log_error ^= 1;
if(check_key(KEY_F6)) debug_on ^= 1;
@ -315,11 +364,7 @@ void dos_update_input(void)
f = fopen("game.gpz","r+b");
if (f)
{
int len = 0;
fread(&len, 4, 1, f);
fclose(f);
fopen("game.gpz","r+b");
fread(&buf, len+4, 1, f);
fread(&buf, 0x23000, 1, f);
state_load(buf);
fclose(f);
}
@ -330,18 +375,22 @@ void dos_update_input(void)
f = fopen("game.gpz","w+b");
if (f)
{
int size = state_save(buf);
fwrite(&buf, size, 1, f);
state_save(buf);
fwrite(&buf, 0x23000, 1, f);
fclose(f);
}
}
if(check_key(KEY_F9))
{
vdp_pal ^= 1;
system_init();
audio_init(option.sndrate);
fm_restore();
if(check_key(KEY_F9))
{
vdp_pal ^= 1;
/* reinitialize timings */
system_init ();
audio_init(48000);
fm_restore();
/* reinitialize HVC tables */
vctab = (vdp_pal) ? ((reg[1] & 8) ? vc_pal_240 : vc_pal_224) : vc_ntsc_224;
hctab = (reg[12] & 1) ? cycle2hc40 : cycle2hc32;
@ -349,30 +398,13 @@ void dos_update_input(void)
bitmap.viewport.x = config.overscan ? ((reg[12] & 1) ? 16 : 12) : 0;
bitmap.viewport.y = config.overscan ? (((reg[1] & 8) ? 0 : 8) + (vdp_pal ? 24 : 0)) : 0;
bitmap.viewport.changed = 1;
}
if(check_key(KEY_F10))
system_reset();
if(check_key(KEY_F11))
{
joynum ++;
if (joynum > MAX_DEVICES - 1) joynum = 0;
while (input.dev[joynum] == NO_DEVICE)
{
joynum ++;
if (joynum > MAX_DEVICES - 1) joynum = 0;
}
}
if(check_key(KEY_F12))
{
input.x_offset ++;
if (input.x_offset > 0xff) input.x_offset = 0;
}
if(check_key(KEY_F10))
{
system_reset();
}
if(check_key(KEY_TAB))
resetline = (int) ((double) (lines_per_frame - 1) * rand() / (RAND_MAX + 1.0));
if(check_key(KEY_TAB)) set_softreset();
}
void dos_update_audio(void)
@ -470,7 +502,7 @@ void dos_update_video(void)
}*/
msg_print(2, 2, "%d fps", frame_rate);
msg_print(2, 2, "offset = 0x%x", hc_latch/*frame_rate*/);
if(option.scanlines)
{

View File

@ -17,8 +17,26 @@ void make_vdp_palette(void);
void dos_change_mode(void);
int check_key(int code);
#define update_input() dos_update_input()
#define MAX_INPUTS 8
/* options */
extern uint8 overscan;
extern uint8 use_480i;
extern uint8 FM_GENS;
extern uint8 hq_fm;
extern uint8 ssg_enabled;
extern double psg_preamp;
extern double fm_preamp;
extern uint8 boost;
extern uint8 region_detect;
extern uint8 sys_type[2];
extern uint8 force_dtack;
extern uint8 dmatiming;
extern uint8 vdptiming;
extern uint8 debug_on;
extern uint8 log_error;
extern int frame_count;
#endif /* _DOS_H_ */

View File

@ -11,20 +11,20 @@ struct {
void error_init(void)
{
error_log = fopen("error.log","w");
error_log = fopen("error.log","w");
}
void error_shutdown(void)
{
if(error_log) fclose(error_log);
if(error_log) fclose(error_log);
}
void error(char *format, ...)
{
if (!log_error) return;
va_list ap;
va_start(ap, format);
if(error_log) vfprintf(error_log, format, ap);
va_end(ap);
va_start(ap, format);
if(error_log) vfprintf(error_log, format, ap);
va_end(ap);
}

View File

@ -17,6 +17,5 @@
#include "unzip.h"
#include "fileio.h"
#define update_input() dos_update_input()
volatile int frame_count;
#endif /* _OSD_H_ */

View File

@ -0,0 +1,3 @@
To be compiled with DJGPP.
You will also need to install Allegro and Seal libraries.
Zlib is required for zipped rom support.

View File

@ -1 +0,0 @@
@make.exe -f makefile.mgw %1

View File

@ -1,107 +0,0 @@
# Genesis Plus - Sega Mega Drive emulator
# (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald
# -DLSB_FIRST - Leave undefined for big-endian processors.
# -DDEBUG - Enable debugging code
# -DX86_ASM - Enable inline x86 assembly code in Z80 emulator
CC = gcc
AS = nasm -f coff
LDFLAGS =
FLAGS = -I. -Icpu -Im68k -Iwin -Isound -Icart_hw -Icart_hw\svp \
-Ic:/SDL/include/SDL \
-Werror -Wall \
-DLSB_FIRST -DX86_ASM \
-O6 -march=pentium -fomit-frame-pointer
LIBS = -lz -lm -lmingw32 -Ld:/sdl/lib -lSDLmain -lSDL obj/m68k.oa
OBJ = obj/z80.oa \
obj/genesis.o \
obj/vdp.o \
obj/render.o \
obj/system.o \
obj/io.o \
obj/input.o \
obj/mem68k.o \
obj/memz80.o \
obj/membnk.o \
obj/memvdp.o \
obj/state.o
OBJ += obj/sound.o \
obj/fm.o \
obj/sn76489.o \
obj/ym2612.o
OBJ += obj/sram.o \
obj/eeprom.o \
obj/svp.o \
obj/ssp16.o \
obj/cart_hw.o
OBJ += obj/main.o \
obj/error.o \
obj/fileio.o \
obj/unzip.o \
obj/loadrom.o
EXE = gen.exe
all : $(EXE)
$(EXE) : $(OBJ) shared.h
$(CC) -o $(EXE) $(OBJ) $(LIBS) $(LDFLAGS)
obj/%.oa : cpu/%.c cpu/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : %.c %.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : win/%.s
$(AS) $< -o $@
obj/%.o : sound/%.c sound/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : cpu/%.c cpu/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : win/%.c win/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : cart_hw/%.c cart_hw/%.h
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : cart_hw/svp/%.c
$(CC) -c $< -o $@ $(FLAGS)
obj/%.o : cart_hw/svp/%.c cart_hw/svp/%.h
$(CC) -c $< -o $@ $(FLAGS)
pack :
strip $(EXE)
upx -1 $(EXE)
clean :
rm -f obj/*.o
rm -f *.bak
rm -f *.exe
rm -f *.log
rm -f *.wav
rm -f *.zip
cleancpu :
rm -f obj/z80.oa
makedir :
mkdir obj
archive:
pk -add -max -excl=bak -excl=out \
-excl=test -excl=obj mdsrc.zip -dir=current
#
# end of makefile
#

File diff suppressed because it is too large Load Diff

View File

@ -1,274 +0,0 @@
/* unzip.h -- IO for uncompress .zip files using zlib
Version 0.15 beta, Mar 19th, 1998,
Copyright (C) 1998 Gilles Vollant
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
WinZip, InfoZip tools and compatible.
Encryption and multi volume ZipFile (span) are not supported.
Old compressions used by old PKZip 1.x are not supported
THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE
CAN CHANGE IN FUTURE VERSION !!
I WAIT FEEDBACK at mail info@winimage.com
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
Condition of use and distribution are the same than zlib :
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
/* for more info about .ZIP format, see
ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip
PkWare has also a specification at :
ftp://ftp.pkware.com/probdesc.zip */
#ifndef _unz_H
#define _unz_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _ZLIB_H
#include "zlib.h"
#endif
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
/* like the STRICT of WIN32, we define a pointer that cannot be converted
from (void*) without cast */
typedef struct TagunzFile__ { int unused; } unzFile__;
typedef unzFile__ *unzFile;
#else
typedef voidp unzFile;
#endif
#define UNZ_OK (0)
#define UNZ_END_OF_LIST_OF_FILE (-100)
#define UNZ_ERRNO (Z_ERRNO)
#define UNZ_EOF (0)
#define UNZ_PARAMERROR (-102)
#define UNZ_BADZIPFILE (-103)
#define UNZ_INTERNALERROR (-104)
#define UNZ_CRCERROR (-105)
/* tm_unz contain date/time info */
typedef struct tm_unz_s
{
uInt tm_sec; /* seconds after the minute - [0,59] */
uInt tm_min; /* minutes after the hour - [0,59] */
uInt tm_hour; /* hours since midnight - [0,23] */
uInt tm_mday; /* day of the month - [1,31] */
uInt tm_mon; /* months since January - [0,11] */
uInt tm_year; /* years - [1980..2044] */
} tm_unz;
/* unz_global_info structure contain global data about the ZIPfile
These data comes from the end of central dir */
typedef struct unz_global_info_s
{
uLong number_entry; /* total number of entries in
the central dir on this disk */
uLong size_comment; /* size of the global comment of the zipfile */
} unz_global_info;
/* unz_file_info contain information about a file in the zipfile */
typedef struct unz_file_info_s
{
uLong version; /* version made by 2 bytes */
uLong version_needed; /* version needed to extract 2 bytes */
uLong flag; /* general purpose bit flag 2 bytes */
uLong compression_method; /* compression method 2 bytes */
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
uLong crc; /* crc-32 4 bytes */
uLong compressed_size; /* compressed size 4 bytes */
uLong uncompressed_size; /* uncompressed size 4 bytes */
uLong size_filename; /* filename length 2 bytes */
uLong size_file_extra; /* extra field length 2 bytes */
uLong size_file_comment; /* file comment length 2 bytes */
uLong disk_num_start; /* disk number start 2 bytes */
uLong internal_fa; /* internal file attributes 2 bytes */
uLong external_fa; /* external file attributes 4 bytes */
tm_unz tmu_date;
} unz_file_info;
extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
const char* fileName2,
int iCaseSensitivity));
/*
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
or strcasecmp)
If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
(like 1 on Unix, 2 on Windows)
*/
extern unzFile ZEXPORT unzOpen OF((const char *path));
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer
"zlib/zlib111.zip".
If the zipfile cannot be opened (file don't exist or in not valid), the
return value is NULL.
Else, the return value is a unzFile Handle, usable with other function
of this unzip package.
*/
extern int ZEXPORT unzClose OF((unzFile file));
/*
Close a ZipFile opened with unzipOpen.
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
unz_global_info *pglobal_info));
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
char *szComment,
uLong uSizeBuf));
/*
Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer.
return the number of byte copied or an error code <0
*/
/***************************************************************************/
/* Unzip package allow you browse the directory of the zipfile */
extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
/*
Set the current file of the zipfile to the first file.
return UNZ_OK if there is no problem
*/
extern int ZEXPORT unzGoToNextFile OF((unzFile file));
/*
Set the current file of the zipfile to the next file.
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
extern int ZEXPORT unzLocateFile OF((unzFile file,
const char *szFileName,
int iCaseSensitivity));
/*
Try locate the file szFileName in the zipfile.
For the iCaseSensitivity signification, see unzStringFileNameCompare
return value :
UNZ_OK if the file is found. It becomes the current file.
UNZ_END_OF_LIST_OF_FILE if the file is not found
*/
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
unz_file_info *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
uLong commentBufferSize));
/*
Get Info about the current file
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
the current file
if szFileName!=NULL, the filemane string will be copied in szFileName
(fileNameBufferSize is the size of the buffer)
if extraField!=NULL, the extra field information will be copied in extraField
(extraFieldBufferSize is the size of the buffer).
This is the Central-header version of the extra field
if szComment!=NULL, the comment string of the file will be copied in szComment
(commentBufferSize is the size of the buffer)
*/
/***************************************************************************/
/* for reading the content of the current zipfile, you can open it, read data
from it, and close it (you can close it before reading all the file)
*/
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
/*
Open for reading data the current file in the zipfile.
If there is no error, the return value is UNZ_OK.
*/
extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
/*
Close the file in zip opened with unzOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
voidp buf,
unsigned len));
/*
Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied
len the size of buf.
return the number of byte copied if somes bytes are copied
return 0 if the end of file was reached
return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
extern z_off_t ZEXPORT unztell OF((unzFile file));
/*
Give the current position in uncompressed data
*/
extern int ZEXPORT unzeof OF((unzFile file));
/*
return 1 if the end of file was reached, 0 elsewhere
*/
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
voidp buf,
unsigned len));
/*
Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
more info in the local-header version than in the central-header)
if buf==NULL, it return the size of the local extra field
if buf!=NULL, len is the size of the buffer, the extra header is copied in
buf.
the return value is the number of bytes copied in buf, or (if <0)
the error code
*/
#ifdef __cplusplus
}
#endif
#endif /* _unz_H */

105
source/unused/win/Makefile Normal file
View File

@ -0,0 +1,105 @@
# Makefile for genplus SDL
#
# (c) 1999, 2000, 2001, 2002, 2003 Charles MacDonald
# modified by Eke-Eke <eke_eke31@yahoo.fr>
#
# Defines :
# LSB_FIRST : for little endian systems.
# X86_ASM : enable x86 assembly optimizations
NAME = gp_sdl
CC = gcc
CFLAGS = `sdl-config --cflags` -O6 -march=i686 -fomit-frame-pointer
DEFINES = -DLSB_FIRST -DX86_ASM
INCLUDES = -I. -I.. -I../cpu -I../m68k -I../dos -I../sound -I../sound/SRC -I../cart_hw -I../cart_hw/svp
LIBS = `sdl-config --libs` -lz -lm
OBJECTS = obj/z80.o
OBJECTS += obj/m68kcpu.o \
obj/m68kops.o
OBJECTS += obj/genesis.o \
obj/vdp.o \
obj/render.o \
obj/system.o \
obj/gen_io.o \
obj/gen_input.o \
obj/mem68k.o \
obj/memz80.o \
obj/membnk.o \
obj/memvdp.o \
obj/state.o
OBJECTS += obj/sound.o \
obj/fm.o \
obj/sn76489.o \
obj/ym2612.o
OBJECTS += obj/samplerate.o \
obj/src_linear.o \
obj/src_sinc.o \
obj/src_zoh.o \
OBJECTS += obj/sram.o \
obj/eeprom.o \
obj/svp.o \
obj/ssp16.o \
obj/cart_hw.o
OBJECTS += obj/main.o \
obj/config.o \
obj/error.o \
obj/unzip.o \
obj/fileio.o \
obj/loadrom.o
all: $(NAME)
$(NAME): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
obj/%.o : ../%.c ../%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../asm/%.s
$(AS) $< -o $@
obj/%.o : ../sound/%.c ../sound/%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../sound/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../sound/SRC/%.c ../sound/SRC/%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../sound/SRC/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../cart_hw/%.c ../cart_hw/%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../cart_hw/svp/%.c
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../cart_hw/svp/%.c ../cart_hw/svp/%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../cpu/%.c ../cpu/%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ../m68k/%.c ../m68k/%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
obj/%.o : ./%.c ./%.h
$(CC) -c $(CFLAGS) $(INCLUDES) $(DEFINES) $< -o $@
pack :
strip $(EXE)
upx -1 $(EXE)
clean:
rm -f $(OBJECTS) $(NAME)

View File

@ -0,0 +1,43 @@
#include "osd.h"
#define CONFIG_VERSION "GENPLUS 1.2.1 "
t_config config;
void set_config_defaults(void)
{
/* version TAG */
strncpy(config.version,CONFIG_VERSION,15);
/* sound options */
config.psg_preamp = 1.5;
config.fm_preamp = 1.0;
config.boost = 1;
config.filter = 0;
config.hq_fm = 1;
config.fm_core = 0;
/* system options */
config.freeze_auto = -1;
config.sram_auto = -1;
config.region_detect = 0;
config.force_dtack = 0;
config.bios_enabled = 0;
/* display options */
config.xshift = 0;
config.yshift = 0;
config.xscale = 0;
config.yscale = 0;
config.aspect = 1;
config.overscan = 1;
config.render = 0;
/* controllers options */
config.gun_cursor = 1;
config.invert_mouse = 0;
}

View File

@ -0,0 +1,39 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_
/****************************************************************************
* Config Option
*
****************************************************************************/
typedef struct
{
char version[15];
double psg_preamp;
double fm_preamp;
uint8 boost;
uint8 filter;
uint8 hq_fm;
uint8 fm_core;
int8 sram_auto;
int8 freeze_auto;
uint8 region_detect;
uint8 force_dtack;
uint8 bios_enabled;
int16 xshift;
int16 yshift;
int16 xscale;
int16 yscale;
uint8 tv_mode;
uint8 aspect;
uint8 overscan;
uint8 render;
uint8 gun_cursor;
uint8 invert_mouse;
} t_config;
/* Global variables */
extern t_config config;
#endif /* _CONFIG_H_ */

View File

@ -1,9 +1,5 @@
/*
error.c --
Error logging
*/
#include "shared.h"
#include "osd.h"
FILE *error_log;
@ -15,25 +11,20 @@ struct {
void error_init(void)
{
#ifdef DEBUG
error_log = fopen("error.log","w");
#endif
error_log = fopen("error.log","w");
}
void error_shutdown(void)
{
#ifdef DEBUG
if(error_log) fclose(error_log);
#endif
if(error_log) fclose(error_log);
}
void error(char *format, ...)
{
#ifdef DEBUG
va_list ap;
va_start(ap, format);
if(error_log) vfprintf(error_log, format, ap);
va_end(ap);
#endif
if (!log_error) return;
va_list ap;
va_start(ap, format);
if(error_log) vfprintf(error_log, format, ap);
va_end(ap);
}

151
source/unused/win/fileio.c Normal file
View File

@ -0,0 +1,151 @@
#include "shared.h"
/*
Load a normal file, or ZIP/GZ archive.
Returns NULL if an error occured.
*/
uint8 *load_archive(char *filename, int *file_size)
{
int size = 0;
uint8 *buf = NULL;
if(check_zip(filename))
{
unzFile *fd = NULL;
unz_file_info info;
int ret = 0;
/* Attempt to open the archive */
fd = unzOpen(filename);
if(!fd) return (NULL);
/* Go to first file in archive */
ret = unzGoToFirstFile(fd);
if(ret != UNZ_OK)
{
unzClose(fd);
return (NULL);
}
ret = unzGetCurrentFileInfo(fd, &info, NULL, 0, NULL, 0, NULL, 0);
if(ret != UNZ_OK)
{
unzClose(fd);
return (NULL);
}
/* Open the file for reading */
ret = unzOpenCurrentFile(fd);
if(ret != UNZ_OK)
{
unzClose(fd);
return (NULL);
}
/* Allocate file data buffer */
size = info.uncompressed_size;
buf = malloc(size);
if(!buf)
{
unzClose(fd);
return (NULL);
}
/* Read (decompress) the file */
ret = unzReadCurrentFile(fd, buf, info.uncompressed_size);
if(ret != info.uncompressed_size)
{
free(buf);
unzCloseCurrentFile(fd);
unzClose(fd);
return (NULL);
}
/* Close the current file */
ret = unzCloseCurrentFile(fd);
if(ret != UNZ_OK)
{
free(buf);
unzClose(fd);
return (NULL);
}
/* Close the archive */
ret = unzClose(fd);
if(ret != UNZ_OK)
{
free(buf);
return (NULL);
}
/* Update file size and return pointer to file data */
*file_size = size;
return (buf);
}
else
{
gzFile *gd = NULL;
/* Open file */
gd = gzopen(filename, "rb");
if(!gd) return (0);
/* Get file size */
size = gzsize(gd);
/* Allocate file data buffer */
buf = malloc(size);
if(!buf)
{
gzclose(gd);
return (0);
}
/* Read file data */
gzread(gd, buf, size);
/* Close file */
gzclose(gd);
/* Update file size and return pointer to file data */
*file_size = size;
return (buf);
}
}
/*
Verifies if a file is a ZIP archive or not.
Returns: 1= ZIP archive, 0= not a ZIP archive
*/
int check_zip(char *filename)
{
uint8 buf[2];
FILE *fd = NULL;
fd = fopen(filename, "rb");
if(!fd) return (0);
fread(buf, 2, 1, fd);
fclose(fd);
if(memcmp(buf, "PK", 2) == 0) return (1);
return (0);
}
/*
Returns the size of a GZ compressed file.
*/
int gzsize(gzFile *gd)
{
#define CHUNKSIZE (0x10000)
int size = 0, length = 0;
unsigned char buffer[CHUNKSIZE];
gzrewind(gd);
do {
size = gzread(gd, buffer, CHUNKSIZE);
if(size <= 0) break;
length += size;
} while (!gzeof(gd));
gzrewind(gd);
return (length);
#undef CHUNKSIZE
}

View File

@ -0,0 +1,14 @@
#ifndef _FILEIO_H_
#define _FILEIO_H_
/* Global variables */
extern int cart_size;
extern char cart_name[0x100];
/* Function prototypes */
uint8 *load_archive(char *filename, int *file_size);
int load_cart(char *filename);
int check_zip(char *filename);
int gzsize(gzFile *gd);
#endif /* _FILEIO_H_ */

View File

@ -11,18 +11,6 @@ int frame_count = 0;
int update_input(void);
unsigned char *keystate;
/* Options default */
uint8 overscan = 1;
uint8 use_480i = 1;
uint8 FM_GENS = 1;
uint8 hq_fm = 1;
double psg_preamp = 0.5;
double fm_preamp = 1.0;
uint8 boost = 1;
uint8 region_detect = 0;
uint8 sys_type[2] = {0,0};
uint8 force_dtack = 0;
uint8 log_error = 1;
uint8 debug_on = 0;
@ -35,7 +23,7 @@ Uint32 fps_callback(Uint32 interval)
{
int fps = frame_count;
char caption[32];
sprintf(caption, "Genesis Plus/SDL FPS=%d", fps);
sprintf(caption, "Genesis Plus/SDL FPS=%d", fps);
SDL_WM_SetCaption(caption, NULL);
frame_count = 0;
}
@ -47,23 +35,25 @@ int main (int argc, char **argv)
{
int running = 1;
SDL_Rect viewport, src;
SDL_Surface *bmp, *screen;
SDL_Event event;
SDL_Rect viewport, src;
SDL_Surface *bmp, *screen;
SDL_Event event;
error_init();
error_init();
/* Print help if no game specified */
/* Print help if no game specified */
if(argc < 2)
{
char caption[256];
sprintf(caption, "Genesis Plus\nby Charles MacDonald\nWWW: http://cgfm2.emuviews.com\nusage: %s gamename\n", argv[0]);
MessageBox(NULL, caption, "Information", 0);
sprintf(caption, "Genesis Plus\nby Charles MacDonald\nWWW: http://cgfm2.emuviews.com\nusage: %s gamename\n", argv[0]);
MessageBox(NULL, caption, "Information", 0);
exit(1);
}
/* Load game */
if(!load_rom(argv[1]))
cart_rom = malloc(0xA00000);
memset(cart_rom, 0, 0xA00000);
if(!load_rom(argv[1]))
{
char caption[256];
sprintf(caption, "Error loading file `%s'.", argv[1]);
@ -71,52 +61,77 @@ int main (int argc, char **argv)
exit(1);
}
viewport.x = 0;
viewport.y = 0;
viewport.w = 256;
viewport.h = 224;
/* load SRAM */
FILE *f = fopen("./game.srm", "rb");
if (f!=NULL)
{
fread(&sram.sram,0x10000,1, f);
fclose(f);
}
src.x = 32;
src.y = 0;
src.w = viewport.w;
src.h = viewport.h;
/* load BIOS */
memset(bios_rom, 0, sizeof(bios_rom));
f = fopen("./BIOS.bin", "rb");
if (f!=NULL)
{
fread(&bios_rom, 0x800,1,f);
fclose(f);
int i;
for(i = 0; i < 0x800; i += 2)
{
uint8 temp = bios_rom[i];
bios_rom[i] = bios_rom[i+1];
bios_rom[i+1] = temp;
}
config.bios_enabled = 3;
}
else config.bios_enabled = 0;
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
{
exit(1);
}
SDL_WM_SetCaption("Genesis Plus/SDL", NULL);
/* initialize SDL */
viewport.w = 640;
viewport.h = 480;
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0)
{
exit(1);
}
SDL_WM_SetCaption("Genesis Plus/SDL", NULL);
screen = SDL_SetVideoMode(viewport.w, viewport.h, 16, SDL_HWSURFACE);
bmp = SDL_CreateRGBSurface(SDL_SWSURFACE, 1024, 512, 16, 0xF800, 0x07E0, 0x001F, 0x0000);
screen = SDL_SetVideoMode(viewport.w, viewport.h, 16, SDL_SWSURFACE);
viewport.x = 0;
viewport.y = 0;
/* initialize Genesis screen */
memset(&bitmap, 0, sizeof(t_bitmap));
bitmap.width = 1024;
bitmap.height = 512;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.pitch = (bitmap.width * bitmap.granularity);
bitmap.data = (unsigned char *)bmp->pixels;
bitmap.viewport.w = 256;
bitmap.viewport.h = 224;
bitmap.viewport.x = 0;
bitmap.viewport.y = 0;
bitmap.remap = 1;
bmp = SDL_CreateRGBSurface(SDL_SWSURFACE, 1024, 512, 16, 0xF800, 0x07E0, 0x001F, 0x0000);
/* default config */
set_config_defaults();
input.system[0] = SYSTEM_GAMEPAD;
input.system[1] = SYSTEM_GAMEPAD;
/* initialize emulation */
int buf_len = (44100 * 4) / vdp_rate;
snd.buffer[0] = malloc (buf_len/2);
snd.buffer[1] = malloc (buf_len/2);
memset (snd.buffer[0], 0, buf_len/2);
memset (snd.buffer[1], 0, buf_len/2);
system_init();
audio_init(44100);
system_reset();
memset(&bitmap, 0, sizeof(t_bitmap));
bitmap.width = 1024;
bitmap.height = 512;
bitmap.depth = 16;
bitmap.granularity = 2;
bitmap.pitch = (bitmap.width * bitmap.granularity);
bitmap.data = (unsigned char *)bmp->pixels;
bitmap.viewport.w = 256;
bitmap.viewport.h = 224;
bitmap.viewport.x = 0x20;
bitmap.viewport.y = 0x00;
bitmap.remap = 1;
system_init();
system_reset();
SDL_SetTimer(1000/60, fps_callback);
/* emulation loop */
SDL_SetTimer(1000/60, fps_callback);
while(running)
{
running = update_input();
while (SDL_PollEvent(&event))
{
switch(event.type)
@ -141,78 +156,75 @@ int main (int argc, char **argv)
{
frame_count++;
update_input();
if(!system_frame(0))
system_reset();
if(!system_frame(0))
system_reset();
if(bitmap.viewport.changed)
{
bitmap.viewport.changed = 0;
src.w = bitmap.viewport.w;
src.h = bitmap.viewport.h;
viewport.w = bitmap.viewport.w;
viewport.h = bitmap.viewport.h;
screen = SDL_SetVideoMode(bitmap.viewport.w, bitmap.viewport.h, 16, SDL_SWSURFACE);
}
SDL_BlitSurface(bmp, &src, screen, &viewport);
SDL_UpdateRect(screen, viewport.x, viewport.y, viewport.w, viewport.h);
}
if(bitmap.viewport.changed)
{
bitmap.viewport.changed = 0;
src.w = (bitmap.viewport.w + 2 * bitmap.viewport.x);
src.h = (bitmap.viewport.h + 2 * bitmap.viewport.y) << (interlaced ? 1:0);
viewport.w = src.w;
viewport.h = src.h;
viewport.x = (640 - viewport.w) / 2;
viewport.y = (480 - viewport.h) / 2;
//screen = SDL_SetVideoMode(bitmap.viewport.w, bitmap.viewport.h, 16, SDL_SWSURFACE);
SDL_BlitSurface(bmp, &src, screen, &viewport);
SDL_UpdateRect(screen, viewport.x, viewport.y, viewport.w, viewport.h);
}
}
}
system_shutdown();
SDL_Quit();
error_shutdown();
system_shutdown();
SDL_Quit();
error_shutdown();
return 0;
return 0;
}
/* Check if a key is pressed */
int check_key(int code)
{
static char lastbuf[0x100] = {0};
static char lastbuf[0x100] = {0};
if((!keystate[code]) && (lastbuf[code] == 1))
lastbuf[code] = 0;
if((!keystate[code]) && (lastbuf[code] == 1))
lastbuf[code] = 0;
if((keystate[code]) && (lastbuf[code] == 0))
{
lastbuf[code] = 1;
return (1);
}
if((keystate[code]) && (lastbuf[code] == 0))
{
lastbuf[code] = 1;
return (1);
}
return (0);
return (0);
}
int update_input(void)
{
int running = 1;
int running = 1;
keystate = SDL_GetKeyState(NULL);
keystate = SDL_GetKeyState(NULL);
memset(&input, 0, sizeof(t_input));
if(keystate[SDLK_UP]) input.pad[0] |= INPUT_UP;
else
if(keystate[SDLK_DOWN]) input.pad[0] |= INPUT_DOWN;
if(keystate[SDLK_LEFT]) input.pad[0] |= INPUT_LEFT;
else
if(keystate[SDLK_RIGHT]) input.pad[0] |= INPUT_RIGHT;
memset(&input, 0, sizeof(t_input));
if(keystate[SDLK_UP]) input.pad[0] |= INPUT_UP;
else
if(keystate[SDLK_DOWN]) input.pad[0] |= INPUT_DOWN;
if(keystate[SDLK_LEFT]) input.pad[0] |= INPUT_LEFT;
else
if(keystate[SDLK_RIGHT]) input.pad[0] |= INPUT_RIGHT;
if(keystate[SDLK_a]) input.pad[0] |= INPUT_A;
if(keystate[SDLK_s]) input.pad[0] |= INPUT_B;
if(keystate[SDLK_d]) input.pad[0] |= INPUT_C;
if(keystate[SDLK_f]) input.pad[0] |= INPUT_START;
if(keystate[SDLK_z]) input.pad[0] |= INPUT_X;
if(keystate[SDLK_x]) input.pad[0] |= INPUT_Y;
if(keystate[SDLK_c]) input.pad[0] |= INPUT_Z;
if(keystate[SDLK_v]) input.pad[0] |= INPUT_MODE;
if(keystate[SDLK_a]) input.pad[0] |= INPUT_A;
if(keystate[SDLK_s]) input.pad[0] |= INPUT_B;
if(keystate[SDLK_d]) input.pad[0] |= INPUT_C;
if(keystate[SDLK_f]) input.pad[0] |= INPUT_START;
if(keystate[SDLK_z]) input.pad[0] |= INPUT_X;
if(keystate[SDLK_x]) input.pad[0] |= INPUT_Y;
if(keystate[SDLK_c]) input.pad[0] |= INPUT_Z;
if(keystate[SDLK_v]) input.pad[0] |= INPUT_MODE;
if(keystate[SDLK_TAB]) system_reset();
if(keystate[SDLK_TAB]) system_reset();
if(keystate[SDLK_ESCAPE]) running = 0;
return (running);
if(keystate[SDLK_ESCAPE]) running = 0;
return (running);
}

View File

@ -2,17 +2,8 @@
#ifndef _MAIN_H_
#define _MAIN_H_
/* options */
extern uint8 overscan;
extern uint8 use_480i;
extern uint8 FM_GENS;
extern uint8 hq_fm;
extern double psg_preamp;
extern double fm_preamp;
extern uint8 boost;
extern uint8 region_detect;
extern uint8 sys_type[2];
extern uint8 force_dtack;
#define MAX_INPUTS 8
extern uint8 debug_on;
extern uint8 log_error;

View File

@ -8,12 +8,13 @@
#include <time.h>
#include <conio.h>
#include "SDL.h"
#include <SDL.h>
#include <stdlib.h>
#include "error.h"
#include "shared.h"
#include "main.h"
#include "config.h"
#include "error.h"
#include "unzip.h"
#include "fileio.h"

View File

@ -0,0 +1,3 @@
To be compiled with MinGW.
You will also need to install SDL library
Zlib is required for zipped rom support.

View File

@ -161,7 +161,7 @@ local int unzlocal_getShort (fin,pX)
uLong *pX;
{
uLong x ;
int i;
int i = 0;
int err;
err = unzlocal_getByte(fin,&i);
@ -183,7 +183,7 @@ local int unzlocal_getLong (fin,pX)
uLong *pX;
{
uLong x ;
int i;
int i = 0;
int err;
err = unzlocal_getByte(fin,&i);