gnuboy: initial 1.0.3 import (last official release)

master
rofl0r 11 years ago
commit 29076d4cef

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, 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
Appendix: 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., 675 Mass Ave, Cambridge, MA 02139, 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.

@ -0,0 +1,81 @@
GNUBOY INSTALLATION
*NIX SYSTEMS
One or more of the following is required to compile on *nix: X, SDL,
svgalib, or Linux fbcon. Since basically everyone has X, this should
not be a problem. Please note that the SDL and fbcon ports are the
most functional, however. In the future, Sun console may also be
supported.
The best and easiest way to build gnuboy for *nix is with the
configure script:
./configure
make
make install
By default, heavy optimization and asm cpu and graphics cores will be
used if available on your platform. For information on compiletime
options related to performance and debugging, type:
./configure --help
Alternatively, if you don't like the GNU configure script, you may
copy the Makefile.nix to Makefile and edit it by hand to work with
your system. Make sure you uncomment -DIS_LITTLE_ENDIAN if your cpu is
little endian. Please note that not everything is supported when
compiling this way, and that it should only be done as a last resort.
The generic Makefile.nix may be removed in the future since it's extra
work to maintain.
Running make should produce the binaries xgnuboy, fbgnuboy, sgnuboy
and/or sdlgnuboy, depending on the availability of the various
interface libraries on your host. The install target will install
these to $(prefix)/bin, where prefix is specified to configure in the
usual way. The default prefix is of course /usr/local/.
Binary packages may be available for some platforms, but they are
usually not quite up to date, and are not built or supported by the
gnuboy team.
Binary package maintainers should be aware that, by default, gnuboy
will be built with optimizations specific to the exact host cpu it's
being compiled on, and may not work on older models. If you want your
binaries to work with older systems too, run configure with the
--disable-arch option to disable architecture specific compiler flags.
WINDOWS
Mingw32 and the SDL development files are required to compile gnuboy
for Windows. They may be obtained from www.mingw.org and
www.libsdl.org, respectively.
Just copy Makefile.mingw32 to Makefile and run make. When done, put
the resulting gnuboy.exe wherever you wish to install it.
Precompiled binaries are also available for Windows; check the site
from which you obtained gnuboy to see if it provides copies.
DOS
You'll need djgpp to use the included Makefile. Theoretically it
shouldn't be hard to port the dos-specific modules to work with other
compilers, but I see no reason why it should be necessary.
Since all DOS systems are basically alike, just copy Makefile.dos to
Makefile and type "make" to compile gnuboy. No configuration should be
necessary. If you do have build problems, let us know.
After compiling, place gnuboy.exe wherever you want.
Precompiled binaries are also available for DOS; check the site from
which you obtained gnuboy to see if it provides copies.

@ -0,0 +1,29 @@
AS = $(CC)
LD = $(CC)
CFLAGS = -O3 -fstrength-reduce -fomit-frame-pointer -I./asm/i386
ASFLAGS = -x assembler-with-cpp
LDFLAGS = -s
THIN_NAMES = tl_main tl_log tl_timer tl_key tl_mouse tl_joy tl_dpp tl_event \
tl_bmp tl_vesa tl_vga tl_video tl_sb tl_sound tl_int
THIN_OBJS = $(THIN_NAMES:%=sys/thinlib/lib/%.o)
SYS_DEFS = -DIS_LITTLE_ENDIAN -DALLOW_UNALIGNED_IO -DALT_PATH_SEP -DUSE_ASM
SYS_INCS = -I./sys/dos -I./sys/thinlib/lib
SYS_OBJS = sys/dos/dos.o sys/thinlib/thinlib.o sys/thinlib/keymap.o $(THIN_OBJS) \
asm/i386/cpu.o asm/i386/lcd.o asm/i386/refresh.o
all: gnuboy.exe
include Rules
gnuboy.exe: $(OBJS) $(SYS_OBJS)
$(LD) $(CFLAGS) $(LDFLAGS) $(OBJS) $(SYS_OBJS) -o $@
clean:
rm -f gnuboy.exe gmon.out *.o sys/*.o sys/dos/*.o sys/pc/*.o asm/i386/*.o \
sys/thinlib/*.o sys/thinlib/*.exe sys/thinlib/*.o

@ -0,0 +1,70 @@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
CC = @CC@
LD = $(CC)
AS = $(CC)
INSTALL = @INSTALL@
CFLAGS = @CFLAGS@
LDFLAGS = $(CFLAGS) @LDFLAGS@
ASFLAGS = $(CFLAGS)
TARGETS = @TARGETS@
ASM_OBJS = @ASM_OBJS@
SYS_DEFS = @DEFS@ @ENDIAN@ @ASM@ @SYS_DEFS@
SYS_OBJS = sys/nix/nix.o $(ASM_OBJS)
SYS_INCS = -I/usr/local/include @XINCS@ -I./sys/nix
FB_OBJS = @FB_OBJS@ @JOY@ @SOUND@
FB_LIBS =
SVGA_OBJS = sys/svga/svgalib.o sys/pc/keymap.o @JOY@ @SOUND@
SVGA_LIBS = -L/usr/local/lib -lvga
SDL_OBJS = sys/sdl/sdl.o sys/sdl/keymap.o
SDL_LIBS = @SDL_LIBS@
SDL_CFLAGS = @SDL_CFLAGS@
X11_OBJS = sys/x11/xlib.o sys/x11/keymap.o @JOY@ @SOUND@
X11_LIBS = @XLIBS@ -lX11 -lXext
all: $(TARGETS)
include Rules
fbgnuboy: $(OBJS) $(SYS_OBJS) $(FB_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(FB_OBJS) -o $@ $(FB_LIBS)
sgnuboy: $(OBJS) $(SYS_OBJS) $(SVGA_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SVGA_OBJS) -o $@ $(SVGA_LIBS)
sdlgnuboy: $(OBJS) $(SYS_OBJS) $(SDL_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SDL_OBJS) -o $@ $(SDL_LIBS)
sys/sdl/sdl.o: sys/sdl/sdl.c
$(MYCC) $(SDL_CFLAGS) -c $< -o $@
sys/sdl/keymap.o: sys/sdl/keymap.c
$(MYCC) $(SDL_CFLAGS) -c $< -o $@
xgnuboy: $(OBJS) $(SYS_OBJS) $(X11_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(X11_OBJS) -o $@ $(X11_LIBS)
install: all
$(INSTALL) -d $(bindir)
$(INSTALL) -m 755 $(TARGETS) $(bindir)
clean:
rm -f *gnuboy gmon.out *.o sys/*.o sys/*/*.o asm/*/*.o
distclean: clean
rm -f config.* sys/nix/config.h Makefile

@ -0,0 +1,64 @@
#
# Makefile.nix
#
# This is a *bare minimum* makefile for building gnuboy on *nix systems.
# If you have trouble with the configure script you can try using this,
# but *please* try the configure script first. This file is mostly
# unmaintained and may break.
#
# If you *do* insist on using this makefile, you at least need to check
# SYS_DEFS below and uncomment -DIS_LITTLE_ENDIAN if your system is
# little endian. Also, you may want to enable the OSS sound module if
# your system supports it.
#
prefix = /usr/local
bindir = /bin
CC = gcc
AS = $(CC)
LD = $(CC)
INSTALL = /bin/install -c
CFLAGS = -O3
LDFLAGS =
ASFLAGS =
SYS_DEFS = #-DIS_LITTLE_ENDIAN
ASM_OBJS =
#SND_OBJS = sys/oss/oss.o
SND_OBJS = sys/dummy/nosound.o
JOY_OBJS = sys/dummy/nojoy.o
TARGETS = xgnuboy
SYS_OBJS = sys/nix/nix.o $(ASM_OBJS) $(SND_OBJS) $(JOY_OBJS)
SYS_INCS = -I/usr/local/include -I/usr/X11R6/include -I./sys/nix
X11_OBJS = sys/x11/xlib.o sys/x11/keymap.o
X11_LIBS = -L/usr/X11R6/lib -lX11 -lXext
all: $(TARGETS)
include Rules
xgnuboy: $(OBJS) $(SYS_OBJS) $(X11_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(X11_OBJS) -o $@ $(X11_LIBS)
install: all
$(INSTALL) -m 755 $(TARGETS) $(prefix)$(bindir)
clean:
rm -f *gnuboy gmon.out *.o sys/*.o sys/*/*.o asm/*/*.o

@ -0,0 +1,31 @@
CC = gcc
AS = $(CC)
LD = $(CC)
CFLAGS = -O3 -I./asm/i386 -Dmain=SDL_main
LDFLAGS = -s -lmingw32 -lSDLmain -lSDL
ASFLAGS = -x assembler-with-cpp
SYS_DEFS = -DIS_LITTLE_ENDIAN -DALT_PATH_SEP -DUSE_ASM
ASM_OBJS = asm/i386/cpu.o asm/i386/lcd.o asm/i386/refresh.o
#SND_OBJS = sys/dummy/nosound.o
SYS_OBJS = $(ASM_OBJS) $(SND_OBJS) sys/windows/windows.o sys/windows/resource.o
SYS_INCS = -I./sys/windows
SDL_OBJS = sys/sdl/sdl.o sys/sdl/keymap.o
SDL_LIBS = -lSDL
all: gnuboy
include Rules
%.o: %.rc
windres -o $@ $<
gnuboy: $(OBJS) $(SYS_OBJS) $(SDL_OBJS)
$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SDL_OBJS) -o $@ $(SDL_LIBS)
clean:
rm -f gnuboy.exe *.o sys/*.o sys/*/*.o asm/*/*.o

199
README

@ -0,0 +1,199 @@
GNUBOY README
INTRO
Welcome to gnuboy, one of the few pieces of Free Software to emulate
the Game Boy handheld game console. Written in ANSI C with a few
optional assembler optimizations for particular cpus, gnuboy supports
a wide range of host systems, and has been tested successfully on:
GNU/Linux
FreeBSD
OpenBSD
BeOS
Linux/390 (IBM S/390 Mainframe)
SunOS/Sun Ultra60
IRIX/SGI O2
IRIX/SGI Indy
AIX/Unknown
DR-DOS
MS-DOS
Windows DOS box
Windows 9x/NT/2k
Additionally, gnuboy should run on any other *nix variants that have
ANSI C compilers and that are remotely POSIX compliant. As gnuboy is
Free Software, you're welcome to fix any problems you encounter
building it for a particular system, or to port it to entirely new
systems.
EMULATION
gnuboy emulates nearly all aspects of the (Color) Gameboy, including
all of the following and much more:
Full GBZ80 instruction set.
Scanline-based LCD engine.
Ten sprites per scanline limit.
Support for all CGB graphics extensions.
Sprite DMA, HDMA, and GDMA.
All four sound channels including digital samples.
MBC1, MBC2, MBC3 (including clock), and MBC5 mappers.
Wave pattern memory corruption when sound channel 3 is played.
Pad, timer, divide counter, and other basic hardware registers.
CGB double-speed CPU mode.
Aspects not emulated at this time include:
* Serial IO (link cable).
Undocumented 'extra' ram in OAM space on Gameboy Color.
All Super Gameboy extensions.
* GBC, HuC1, and HuC3 IR ports.
* Obscure mappers such as TAMA5.
Sorting sprites by X coordinate in DMG mode.
HALT instruction skipping in DMG mode.
CPU stalls during HDMA and GDMA.
Only the two marked by * are known to affect the playability of
actual games or demos; the rest are just listed for completeness'
sake.
FEATURES
In addition to basic emulation, gnuboy provides the following
features:
Highly flexible keybinding and configuration subsystem.
State saving and loading at any point.
Very precise timing/synchronization, preserved across save/load.
Joystick support on Linux, DOS, and all SDL-based ports.
Fully customizable palettes for DMG games.
Screen scaling by a factor of 2, 3, or 4 in all ports.
Hardware-based screen scaling on platforms where it's available.
Debug traces to stdout.
Dynamic palette allocation when run in 256-color modes...
OR simulated 3/3/2 bits per channel in 256-color modes.
For information on configuring and using these features, see the
additional documentation in the "docs" directory.
COMPATIBILITY
Out of over 300 results reported by testers, all games are known to
work perfectly on gnuboy with the following exceptions:
Fighting Phoenix (Japanese) may or may not work since it uses the
HuC1 memory controller, which is not implemented properly. There has
been no report either way so far.
Pocket Bomberman (Japanese version, which uses HuC1) runs, but can
be made to crash if the player jumps into the ceiling in the first
level. It's not clear whether this bug is MBC-related, something
else, or an actual bug in the original game.
Monster Go! Go! Go! (Japanese) is unplayable. The cause of the
problem is not fully known, but it's either a very bad dump or it's
using some sort of specialized MBC that's not documented.
Final Fantasy Adventure has visual problems with the fade between
screens. Does not affect gameplay.
Bubble Bobble 2 has some minor tile glitches right before gameplay
actually begins. Cause unknown. Does not affect gameplay.
Alone in the Dark is reported to have minor visual glitches. I
haven't seen it myself so I can't judge their severity.
Both new Zelda games are reported to have a visual glitch at the
beginning of the game, and on certain other screens. I haven't seen
the problem myself, but supposedly it impacts gameplay to some
extent.
Please report any other incompatibilities discovered directly to
gnuboy@unix-fu.org, so that they can be documented and hopefully
fixed.
FUTURE / WISHLIST
Here's a brief list of what may appear in gnuboy in the future:
Screenshots.
Integrated debugger.
Super Gameboy support.
Serial link over the internet.
Serial link to a real Gameboy with a custom cable.
Configurable color filters to provide more authentic LCD look.
Custom colorization of DMG games on a per-tile basis.
Support for more colorspaces in the hardware scaler.
Recording audio.
GBS player built from the same source tree.
Full recording and playback of emulation.
So-called "high level emulation" of certain typical dumb loops.
Features that are not likely to appear soon or at all include:
Rumble support - this would be nice, but SDL doesn't seem to support
force-feedback yet. We'll see about it in the long-term though.
Eagle/2xSaI/etc. - probably not feasible since these libraries don't
appear to be compatible with the terms of the GPL. We might work on
our own interpolation engine eventually, but that's low priority.
GUI/GUI-like features - such things are best handled by external
front-ends. We might eventually add a mechanism for external
programs to communicate with gnuboy and reconfigure it while it's
running, however.
Plugins - NO! The way I see it, plugins are just an attempt to work
around the GPL. In any case, even if you are adding plugin support
yourself, you are bound by the terms of the GPL when linking ANY
code to gnuboy, including dynamic-linked modules. However we'd
rather not deal with this mess to begin with.
Compressed ROMs/Saves - this one is very iffy. On most systems, this
is redundant; *nix users can just pipe the rom through a
decompression program, and Windows users can just double-click or
drag files from their favorite GUI unzipper program. Linking to zlib
isn't really acceptable since it's massively bloated and we don't
want to include it with gnuboy or add external dependencies. We may,
however, write our own tiny decompressor to use at some point.
Ideas and suggestions for other features are welcome, but won't
necessarily be used. You're of course also free to add features
yourself, and if they fit well into the main tree they may eventually
get included in the official release. See the file HACKING for more
details on modifying and/or contributing.
THANKS
Thanks goes out to everyone who's expressed interest in gnuboy by
writing -- users, porters, authors of other emulators, and so forth.
Apologies if we don't get a personal response out to everyone, but
either way, consider your feedback appreciated.
EPILOGUE
OK, that looks like about it. More to come, stick around...
-Laguna <laguna@aerifal.cx>

31
Rules

@ -0,0 +1,31 @@
include Version
OBJS = lcd.o refresh.o lcdc.o palette.o cpu.o mem.o rtc.o hw.o sound.o \
events.o keytable.o \
loader.o save.o debug.o emu.o main.o \
rccmds.o rckeys.o rcvars.o rcfile.o exports.o \
split.o path.o inflate.o
INCS = -I.
MYCC = $(CC) $(CFLAGS) $(INCS) $(SYS_INCS) $(SYS_DEFS)
MYAS = $(AS) $(ASFLAGS) $(INCS) $(SYS_INCS) $(SYS_DEFS)
main.o: Version
.c.o:
$(MYCC) -c $< -o $@
.s.o:
$(MYAS) -c $< -o $@

@ -0,0 +1,5 @@
#define VERSION "1.0.3" /*
VERSION = 1.0.3
# */

@ -0,0 +1,35 @@
#ifndef __ASM_H__
#define __ASM_H__
#define ASM_CPU_EMULATE
#define ASM_CPU_STEP
#define ASM_REFRESH_1
#define ASM_REFRESH_2
#define ASM_REFRESH_3
#define ASM_REFRESH_4
#define ASM_REFRESH_1_2X
#define ASM_REFRESH_2_2X
#define ASM_REFRESH_4_2X
#define ASM_REFRESH_1_3X
#define ASM_REFRESH_2_3X
#define ASM_REFRESH_4_3X
#define ASM_REFRESH_4_4X
#define ASM_UPDATEPATPIX
#define ASM_BG_SCAN_COLOR
#endif /* __ASM_H__ */

@ -0,0 +1,41 @@
#define cpu _cpu
#define hw _hw
#define ram _ram
#define mbc _mbc
#define lcd _lcd
#define scan _scan
#define patpix _patpix
#define anydirty _anydirty
#define patdirty _patdirty
#define cpu_emulate _cpu_emulate
#define cpu_step _cpu_step
#define lcdc_trans _lcdc_trans
#define debug_trace _debug_trace
#define updatepatpix _updatepatpix
#define debug_disassemble _debug_disassemble
#define bg_scan_color _bg_scan_color
#define refresh_1 _refresh_1
#define refresh_2 _refresh_2
#define refresh_3 _refresh_3
#define refresh_4 _refresh_4
#define refresh_1_2x _refresh_1_2x
#define refresh_2_2x _refresh_2_2x
#define refresh_3_2x _refresh_3_2x
#define refresh_4_2x _refresh_4_2x
#define refresh_1_3x _refresh_1_3x
#define refresh_2_3x _refresh_2_3x
#define refresh_3_3x _refresh_3_3x
#define refresh_4_3x _refresh_4_3x
#define refresh_1_4x _refresh_1_4x
#define refresh_2_4x _refresh_2_4x
#define refresh_3_4x _refresh_3_4x
#define refresh_4_4x _refresh_4_4x
#define mem_read _mem_read
#define mem_write _mem_write
#define cpu_idle _cpu_idle
#define die _die
#define printf _printf

File diff suppressed because it is too large Load Diff

@ -0,0 +1,290 @@
#include "asmnames.h"
.set vram, lcd
.set buf, scan+512
.set pal1, scan+768
.set pal2, scan+896
.set pal4, scan+1024
.set bg, scan
.set buf, scan+512
.set u, scan+1792+24
.set v, scan+1792+28
.set wx, scan+1792+32
.data
.balign 4
.text
.balign 32
debug: .string "%08x\n"
.macro _print arg=0
pushf
pusha
movl \arg, %eax
pushl %eax
pushl $debug
call printf
addl $8, %esp
popa
popf
.endm
.macro _patexpand k=0
movw (%esi,%ecx,2), %ax
andl $(0x0101<<\k), %eax
addb $0xff, %al
sbbb %bl, %bl
addb $0xff, %ah
sbbb %bh, %bh
andl $0x0201, %ebx
orb %bh, %bl
movb %bl, patpix+7-\k(%ebp,%ecx,8)
.endm
.macro _fastswap k=0
movl patpix+(16*\k)(%ebp), %eax
movl patpix+4+(16*\k)(%ebp), %ebx
movl patpix+8+(16*\k)(%ebp), %ecx
movl patpix+12+(16*\k)(%ebp), %edx
bswap %eax
bswap %ebx
bswap %ecx
bswap %edx
movl %eax, patpix+1024*64+4+(16*\k)(%ebp)
movl %ebx, patpix+1024*64+(16*\k)(%ebp)
movl %ecx, patpix+1024*64+12+(16*\k)(%ebp)
movl %edx, patpix+1024*64+8+(16*\k)(%ebp)
.endm
.globl updatepatpix
updatepatpix:
movb anydirty, %al
testb %al, %al
jnz .Lupdatepatpix
ret
.Lupdatepatpix:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
movl $895, %edi
.Lmainloop:
cmpl $511, %edi
jnz .Lnoskip
movl $383, %edi
.Lnoskip:
movb patdirty(%edi), %al
testb %al, %al
jnz .Lpatdirty
decl %edi
jnl .Lmainloop
jmp .Lend
.Lpatdirty:
movb $0, %al
movb %al, patdirty(%edi)
movl %edi, %eax
movl $vram, %esi
shll $4, %eax
addl %eax, %esi
movl $7, %ecx
movl %edi, %ebp
shll $6, %ebp
.Lexpandline:
_patexpand 0
_patexpand 1
_patexpand 2
_patexpand 3
_patexpand 4
_patexpand 5
_patexpand 6
_patexpand 7
decl %ecx
jnl .Lexpandline
_fastswap 0
_fastswap 1
_fastswap 2
_fastswap 3
movl patpix(%ebp), %eax
movl patpix+4(%ebp), %ebx
movl patpix+8(%ebp), %ecx
movl patpix+12(%ebp), %edx
movl %eax, patpix+2048*64+56(%ebp)
movl %ebx, patpix+2048*64+60(%ebp)
movl %ecx, patpix+2048*64+48(%ebp)
movl %edx, patpix+2048*64+52(%ebp)
movl patpix+16(%ebp), %eax
movl patpix+20(%ebp), %ebx
movl patpix+24(%ebp), %ecx
movl patpix+28(%ebp), %edx
movl %eax, patpix+2048*64+40(%ebp)
movl %ebx, patpix+2048*64+44(%ebp)
movl %ecx, patpix+2048*64+32(%ebp)
movl %edx, patpix+2048*64+36(%ebp)
movl patpix+32(%ebp), %eax
movl patpix+36(%ebp), %ebx
movl patpix+40(%ebp), %ecx
movl patpix+44(%ebp), %edx
movl %eax, patpix+2048*64+24(%ebp)
movl %ebx, patpix+2048*64+28(%ebp)
movl %ecx, patpix+2048*64+16(%ebp)
movl %edx, patpix+2048*64+20(%ebp)
movl patpix+48(%ebp), %eax
movl patpix+52(%ebp), %ebx
movl patpix+56(%ebp), %ecx
movl patpix+60(%ebp), %edx
movl %eax, patpix+2048*64+8(%ebp)
movl %ebx, patpix+2048*64+12(%ebp)
movl %ecx, patpix+2048*64(%ebp)
movl %edx, patpix+2048*64+4(%ebp)
movl patpix+1024*64(%ebp), %eax
movl patpix+1024*64+4(%ebp), %ebx
movl patpix+1024*64+8(%ebp), %ecx
movl patpix+1024*64+12(%ebp), %edx
movl %eax, patpix+3072*64+56(%ebp)
movl %ebx, patpix+3072*64+60(%ebp)
movl %ecx, patpix+3072*64+48(%ebp)
movl %edx, patpix+3072*64+52(%ebp)
movl patpix+1024*64+16(%ebp), %eax
movl patpix+1024*64+20(%ebp), %ebx
movl patpix+1024*64+24(%ebp), %ecx
movl patpix+1024*64+28(%ebp), %edx
movl %eax, patpix+3072*64+40(%ebp)
movl %ebx, patpix+3072*64+44(%ebp)
movl %ecx, patpix+3072*64+32(%ebp)
movl %edx, patpix+3072*64+36(%ebp)
movl patpix+1024*64+32(%ebp), %eax
movl patpix+1024*64+36(%ebp), %ebx
movl patpix+1024*64+40(%ebp), %ecx
movl patpix+1024*64+44(%ebp), %edx
movl %eax, patpix+3072*64+24(%ebp)
movl %ebx, patpix+3072*64+28(%ebp)
movl %ecx, patpix+3072*64+16(%ebp)
movl %edx, patpix+3072*64+20(%ebp)
movl patpix+1024*64+48(%ebp), %eax
movl patpix+1024*64+52(%ebp), %ebx
movl patpix+1024*64+56(%ebp), %ecx
movl patpix+1024*64+60(%ebp), %edx
movl %eax, patpix+3072*64+8(%ebp)
movl %ebx, patpix+3072*64+12(%ebp)
movl %ecx, patpix+3072*64(%ebp)
movl %edx, patpix+3072*64+4(%ebp)
decl %edi
jnl .Lmainloop
.Lend:
movb $0, %al
movb %al, anydirty
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.globl bg_scan_color
bg_scan_color:
movb wx, %ch
cmpb $0, %ch
jb .Lbsc_done_nopop
pushl %ebx
pushl %ebp
pushl %esi
pushl %edi
movl v, %eax
movl $bg, %esi
movl $buf, %edi
leal patpix(,%eax,8), %ebp
movl (%esi), %eax
movl u, %ebx
shll $6, %eax
movb $-8, %cl
addl %ebx, %eax
addb %bl, %cl
movb 4(%esi), %bl
addl $8, %esi
addb %cl, %ch
.Lbsc_preloop:
movb (%ebp,%eax), %dl
incl %eax
orb %bl, %dl
movb %dl, (%edi)
incl %edi
incb %cl
jnz .Lbsc_preloop
cmpb $0, %ch
jb .Lbsc_done
subb $8, %ch
.Lbsc_loop:
movl (%esi), %eax
movl 4(%esi), %edx
shll $6, %eax
movb %dl, %dh
addl $8, %esi
movl %edx, %ebx
rorl $16, %edx
orl %edx, %ebx
movl (%ebp,%eax), %edx
orl %ebx, %edx
movl %edx, (%edi)
movl 4(%ebp,%eax), %edx
orl %ebx, %edx
movl %edx, 4(%edi)
addl $8, %edi
subb $8, %ch
jae .Lbsc_loop
addb $8, %ch
jz .Lbsc_done
movl (%esi), %eax
shll $6, %eax
movb 4(%esi), %bl
.Lbsc_postloop:
movb (%ebp,%eax), %dl
incl %eax
orb %bl, %dl
movb %dl, (%edi)
incl %edi
decb %ch
jnz .Lbsc_postloop
.Lbsc_done:
popl %edi
popl %esi
popl %ebp
popl %ebx
.Lbsc_done_nopop:
ret

@ -0,0 +1,285 @@
#include "asmnames.h"
.text
.macro _enter
pushl %ebx
pushl %ebp
pushl %esi
pushl %edi
movl 20(%esp), %edi
movl 24(%esp), %esi
movl 28(%esp), %ebp
movl 32(%esp), %ecx
xorl %eax, %eax
xorl %ebx, %ebx
.endm
.macro _leave
popl %edi
popl %esi
popl %ebp
popl %ebx
ret
.endm
.globl refresh_1
refresh_1:
_enter
subl $4, %esi
subl $4, %edi
shrl $2, %ecx
.Lrefresh_1:
movb 2(%esi,%ecx,4), %al
movb 3(%esi,%ecx,4), %bl
movb (%ebp, %eax), %dl
movb (%esi,%ecx,4), %al
movb (%ebp, %ebx), %dh
movb 1(%esi,%ecx,4), %bl
rorl $16, %edx
movb (%ebp, %eax), %dl
movb (%ebp, %ebx), %dh
movl %edx, (%edi,%ecx,4)
decl %ecx
jnz .Lrefresh_1
_leave
.globl refresh_2
refresh_2:
_enter
subl $2, %esi
subl $4, %edi
shrl $1, %ecx
.Lrefresh_2:
movb 1(%esi,%ecx,2), %al
movb (%esi,%ecx,2), %bl
movw (%ebp,%eax,2), %dx
rorl $16, %edx
movw (%ebp,%ebx,2), %dx
movl %edx, (%edi,%ecx,4)
decl %ecx
jnz .Lrefresh_2
_leave
.globl refresh_3
refresh_3:
_enter
subl $2, %esi
leal (%ecx,%ecx,2), %edx
shrl $1, %ecx
addl %edx, %edi
.Lrefresh_3:
movb (%esi,%ecx,2), %al
subl $6, %edi
movb 1(%esi,%ecx,2), %bl
movl (%ebp,%eax,4), %edx
movb %dl, (%edi)
movb 2(%ebp,%eax,4), %dl
movb %dh, 1(%edi)
movb %dl, 2(%edi)
movl (%ebp,%ebx,4), %edx
movb %dl, 3(%edi)
movb 2(%ebp,%ebx,4), %dl
movb %dh, 4(%edi)
movb %dl, 5(%edi)
decl %ecx
jnz .Lrefresh_3
_leave
.globl refresh_4
refresh_4:
_enter
subl $2, %esi
subl $8, %edi
shrl $1, %ecx
.Lrefresh_4:
movb (%esi,%ecx,2), %al
movb 1(%esi,%ecx,2), %bl
movl (%ebp,%eax,4), %edx
movl %edx, (%edi,%ecx,8)
movl (%ebp,%ebx,4), %edx
movl %edx, 4(%edi,%ecx,8)
decl %ecx
jnz .Lrefresh_4
_leave
.globl refresh_1_2x
refresh_1_2x:
_enter
subl $2, %esi
subl $4, %edi
shrl $1, %ecx
.Lrefresh_1_2x:
movb 1(%esi,%ecx,2), %al
movb (%esi,%ecx,2), %bl
movb (%ebp,%eax), %al
movb %al, %dl
movb %al, %dh
movb (%ebp,%ebx), %bl
rorl $16, %edx
movb %bl, %dl
movb %bl, %dh
movl %edx, (%edi,%ecx,4)
decl %ecx
jnz .Lrefresh_1_2x
_leave
.globl refresh_2_2x
refresh_2_2x:
_enter
subl $2, %esi
subl $8, %edi
shrl $1, %ecx
.Lrefresh_2_2x:
movb (%esi,%ecx,2), %al
movb 1(%esi,%ecx,2), %bl
movw (%ebp,%eax,2), %dx
rorl $16, %edx
movw (%ebp,%eax,2), %dx
movl %edx, (%edi,%ecx,8)
movw (%ebp,%ebx,2), %dx
rorl $16, %edx
movw (%ebp,%ebx,2), %dx
movl %edx, 4(%edi,%ecx,8)
decl %ecx
jnz .Lrefresh_2_2x
_leave
.globl refresh_4_2x
refresh_4_2x:
_enter
subl $2, %esi
subl $16, %edi
.Lrefresh_4_2x:
movb (%esi,%ecx), %al
movb 1(%esi,%ecx), %bl
movl (%ebp,%eax,4), %edx
movl %edx, (%edi,%ecx,8)
movl %edx, 4(%edi,%ecx,8)
movl (%ebp,%ebx,4), %edx
movl %edx, 8(%edi,%ecx,8)
movl %edx, 12(%edi,%ecx,8)
subl $2, %ecx
jnz .Lrefresh_4_2x
_leave
.globl refrsh_1_3x
refresh_1_3x:
_enter
leal (%ecx,%ecx,2), %edx
shrl $1, %ecx
addl %edx, %edi
subl $2, %esi
.Lrefresh_1_3x:
movb (%esi,%ecx,2), %al
subl $6, %edi
movb 1(%esi,%ecx,2), %bl
movb (%ebp,%eax,2), %dl
movb %dl, (%edi)
movb %dl, 1(%edi)
movb %dl, 2(%edi)
movb (%ebp,%ebx,2), %dl
movb %dl, 3(%edi)
movb %dl, 4(%edi)
movb %dl, 5(%edi)
decl %ecx
jnz .Lrefresh_1_3x
_leave
.globl refresh_2_3x
refresh_2_3x:
_enter
shll $1, %ecx
addl %ecx, %edi
addl %ecx, %edi
addl %ecx, %edi
shrl $2, %ecx
subl $2, %esi
.Lrefresh_2_3x:
movb (%esi,%ecx,2), %al
subl $12, %edi
movb 1(%esi,%ecx,2), %bl
movw (%ebp,%eax,2), %dx
movw %dx, (%edi)
movw %dx, 2(%edi)
movw %dx, 4(%edi)
movw (%ebp,%ebx,2), %dx
movw %dx, 6(%edi)
movw %dx, 8(%edi)
movw %dx, 10(%edi)
decl %ecx
jnz .Lrefresh_2_3x
_leave
.globl refresh_4_3x
refresh_4_3x:
_enter
shll $2, %ecx
addl %ecx, %edi
addl %ecx, %edi
addl %ecx, %edi
shrl $3, %ecx
subl $2, %esi
.Lrefresh_4_3x:
movb (%esi,%ecx,2), %al
subl $24, %edi
movb 1(%esi,%ecx,2), %bl
movl (%ebp,%eax,4), %edx
movl %edx, (%edi)
movl %edx, 4(%edi)
movl %edx, 8(%edi)
movl (%ebp,%ebx,4), %edx
movl %edx, 12(%edi)
movl %edx, 16(%edi)
movl %edx, 20(%edi)
decl %ecx
jnz .Lrefresh_4_3x
_leave
.globl refresh_4_4x
refresh_4_4x:
_enter
shll $4, %ecx
addl %ecx, %edi
shrl $5, %ecx
subl $2, %esi
.Lrefresh_4_4x:
movb (%esi,%ecx,2), %al
subl $32, %edi
movb 1(%esi,%ecx,2), %bl
movl (%ebp,%eax,4), %edx
movl %edx, (%edi)
movl %edx, 4(%edi)
movl %edx, 8(%edi)
movl %edx, 12(%edi)
movl (%ebp,%ebx,4), %edx
movl %edx, 16(%edi)
movl %edx, 20(%edi)
movl %edx, 24(%edi)
movl %edx, 28(%edi)
decl %ecx
jnz .Lrefresh_4_4x
_leave

4095
configure vendored

File diff suppressed because it is too large Load Diff

@ -0,0 +1,259 @@
AC_INIT(cpu.c)
CFLAGS="$CFLAGS"
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
test "$cross_compiling" = "yes" || AC_C_BIGENDIAN
test "$ac_cv_c_bigendian" = "no" && ENDIAN="-DIS_LITTLE_ENDIAN"
AC_CHECK_FUNCS(usleep, ,[
AC_CHECK_FUNCS(select, ,[
AC_MSG_ERROR(your system must support either usleep or select)
])])
LIBS="$LIBS -L/usr/local/lib -L/usr/X11R6/lib"